@anker-in/headless-ui 1.3.20 → 1.3.22
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/cjs/biz-components/BuyOneGetOneShelf/ProductCard.d.ts +1 -1
- package/dist/cjs/biz-components/BuyOneGetOneShelf/ProductCard.js +1 -1
- package/dist/cjs/biz-components/BuyOneGetOneShelf/ProductCard.js.map +3 -3
- package/dist/cjs/biz-components/BuyOneGetOneShelf/context.d.ts +4 -0
- package/dist/cjs/biz-components/BuyOneGetOneShelf/context.js +2 -0
- package/dist/cjs/biz-components/BuyOneGetOneShelf/context.js.map +7 -0
- package/dist/cjs/biz-components/BuyOneGetOneShelf/types.d.ts +1 -1
- package/dist/cjs/biz-components/BuyOneGetOneShelf/types.js.map +1 -1
- package/dist/cjs/biz-components/EventSchedule/index.d.ts +2 -2
- package/dist/cjs/biz-components/EventSchedule/index.js +1 -1
- package/dist/cjs/biz-components/EventSchedule/index.js.map +3 -3
- package/dist/cjs/biz-components/FooterNavigation/index.js +1 -1
- package/dist/cjs/biz-components/FooterNavigation/index.js.map +2 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js.map +3 -3
- package/dist/cjs/biz-components/Specs/index.js +1 -1
- package/dist/cjs/biz-components/Specs/index.js.map +3 -3
- package/dist/cjs/components/alert.d.ts +1 -0
- package/dist/cjs/components/alert.js +1 -1
- package/dist/cjs/components/alert.js.map +2 -2
- package/dist/cjs/components/checkbox.js +1 -1
- package/dist/cjs/components/checkbox.js.map +2 -2
- package/dist/cjs/components/dialog.js +1 -1
- package/dist/cjs/components/dialog.js.map +3 -3
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/components/index.js.map +3 -3
- package/dist/cjs/components/otp-input.d.ts +18 -0
- package/dist/cjs/components/otp-input.js +2 -0
- package/dist/cjs/components/otp-input.js.map +7 -0
- package/dist/cjs/helpers/utils.d.ts +7 -1
- package/dist/cjs/helpers/utils.js +1 -1
- package/dist/cjs/helpers/utils.js.map +3 -3
- package/dist/esm/biz-components/BuyOneGetOneShelf/ProductCard.d.ts +1 -1
- package/dist/esm/biz-components/BuyOneGetOneShelf/ProductCard.js +1 -1
- package/dist/esm/biz-components/BuyOneGetOneShelf/ProductCard.js.map +3 -3
- package/dist/esm/biz-components/BuyOneGetOneShelf/context.d.ts +4 -0
- package/dist/esm/biz-components/BuyOneGetOneShelf/context.js +2 -0
- package/dist/esm/biz-components/BuyOneGetOneShelf/context.js.map +7 -0
- package/dist/esm/biz-components/BuyOneGetOneShelf/types.d.ts +1 -1
- package/dist/esm/biz-components/BuyOneGetOneShelf/types.js.map +1 -1
- package/dist/esm/biz-components/EventSchedule/index.d.ts +2 -2
- package/dist/esm/biz-components/EventSchedule/index.js +1 -1
- package/dist/esm/biz-components/EventSchedule/index.js.map +3 -3
- package/dist/esm/biz-components/FooterNavigation/index.js +1 -1
- package/dist/esm/biz-components/FooterNavigation/index.js.map +2 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js +1 -1
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js.map +3 -3
- package/dist/esm/biz-components/Specs/index.js +1 -1
- package/dist/esm/biz-components/Specs/index.js.map +3 -3
- package/dist/esm/components/alert.d.ts +1 -0
- package/dist/esm/components/alert.js +1 -1
- package/dist/esm/components/alert.js.map +2 -2
- package/dist/esm/components/checkbox.js +1 -1
- package/dist/esm/components/checkbox.js.map +2 -2
- package/dist/esm/components/dialog.js +1 -1
- package/dist/esm/components/dialog.js.map +3 -3
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/index.js.map +2 -2
- package/dist/esm/components/otp-input.d.ts +18 -0
- package/dist/esm/components/otp-input.js +2 -0
- package/dist/esm/components/otp-input.js.map +7 -0
- package/dist/esm/helpers/utils.d.ts +7 -1
- package/dist/esm/helpers/utils.js +1 -1
- package/dist/esm/helpers/utils.js.map +3 -3
- package/package.json +1 -1
- package/style.css +42 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{Fragment as T,jsx as t,jsxs as c}from"react/jsx-runtime";import
|
|
1
|
+
"use client";import{Fragment as T,jsx as t,jsxs as c}from"react/jsx-runtime";import q from"./dropdown.js";import{useAiuiContext as Q}from"../AiuiProvider/index.js";import{useMediaQuery as W}from"react-responsive";import{useMemo as G,useState as x,useEffect as C}from"react";import{withLayout as J}from"../../shared/Styles.js";import{formatVariantPrice as K}from"../ShelfDisplay/shelfDisplay.js";import{Picture as v,Text as X,Button as Y,Heading as h}from"../../components/index.js";import{cn as Z}from"../../helpers/index.js";import ee,{useImperativeHandle as te,useRef as se}from"react";const E=ee.forwardRef(({data:k,buildData:d,onChange:A,onSecondaryChange:ne,className:F,...j},H)=>{const u=W({query:"(max-width: 768px)"}),[r,f]=x({}),[b,P]=x([]),[w,y]=x(!1),[g,N]=x({}),S=se(null),{locale:R="us",currencyDisplay:I,trackingData:_}=Q(),$=_?.showComparePrice??!0,{LeftMenu:L,RightMenu:M,DefaultSelectMenu:m}=G(()=>k?.data||{},[k?.data]),O=e=>{try{const n=new URL(e).pathname.toLowerCase();return/\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/.test(n)}catch{return/\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/i.test(e)}},U=(e,s)=>{const n=e?.variants?.find?.(p=>p?.sku===e?.sku),o=n?.coupons?.[0],{price:i,basePrice:a}=K({locale:R||"us",amount:o?o?.variant_price4wscode:n?.price,baseAmount:o?n?.price:0,currencyDisplay:I,currencyCode:e?.price?.currencyCode||"USD"}),l=typeof m?.buttonText=="string"?m?.buttonText:m?.buttonText?.[String(s)]||"";return c("div",{className:"specs-sku-node-wrap box-border",children:[c(X,{className:"md-tablet:p-2 l-tablet:mb-4 l-tablet:text-sm desktop:px-6 lg-desktop:mb-8 lg-desktop:text-lg openDropDown specs-sku-node-text relative mb-6 box-border block rounded-[50px] border border-[#E4E5E6] bg-[#F5F5F7] px-6 py-4 text-base font-bold",onClick:()=>{if(b?.length<=1)return null;N({...g,[s]:!g?.[s]})},children:[c("div",{className:"flex items-center justify-between overflow-hidden",children:[t("div",{className:"openDropDown md-tablet:text-sm lg-desktop:text-lg specs-sku-node-title flex-1 truncate text-base",title:r?.[s]?.name||"",children:r?.[s]?.name||""}),b?.length>1?t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",className:"openDropDown",children:t("path",{d:"M6 9.5L12 15.5L18 9.5",stroke:"#1D1D1F",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):null]}),t(q,{index:s,list:b,active:r,setActive:f,visible:g,setVisible:N})]}),t("div",{className:"lg-desktop:max-h-[196px] lg-desktop:max-w-[196px] max-h-[138px] max-w-[138px]",children:t(v,{source:n?.image?.url||"",className:"aspect-h-[280] aspect-w-[280]",imgClassName:"w-full h-full object-cover hover:scale-105 transition-all duration-300"})}),t("div",{className:"lg-desktop:text-2xl mb-2 mt-6 text-xl font-bold",children:t("div",{className:"lg-desktop:min-h-[32px] flex min-h-[28px] items-center",children:n?.availableForSale?c(T,{children:[t("div",{className:"specs-sku-node-price text-[#080A0F]",children:i||""}),$&&a&&t("div",{className:"lg-desktop:text-2xl specs-sku-node-base-price ml-1 text-xl text-[#86868C] line-through",children:a})]}):null})}),l?t(Y,{onClick:()=>{A?.(e,s)},className:"specs-sku-node-button",children:l}):null]})},V=e=>e&&typeof e!="string"?c("div",{className:"size-full",children:[t("p",{className:"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm",dangerouslySetInnerHTML:{__html:e?.text||""}}),t(v,{source:e?.imgUrl,className:"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]",imgClassName:"w-full h-full object-cover"})]}):t("div",{className:"break-all",children:O(e)?t(v,{source:e,className:"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]",imgClassName:"w-full h-full object-cover"}):t("p",{className:"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm",dangerouslySetInnerHTML:{__html:e||""}})}),D=e=>e.map((s,n)=>{const o=n===0;return c("div",{className:"l-tablet:flex l-tablet:flex-col box-border grid w-full cursor-pointer grid-cols-3 overflow-hidden border-t border-t-[#E4E5E6] specs-product-node-wrap",children:[t(h,{as:"h3",html:s||"",className:"tablet:py-6 l-tablet:text-[#86868C] desktop:p-6 lg-desktop:text-lg specs-product-node-title mr-4 flex-1 pt-4 text-base font-bold md:text-sm"}),t("div",{className:`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:p-6 lg-desktop:gap-16 grid-cols-${w?3:2} specs-product-node-body col-span-2 grid flex-1 py-6`,children:Object.keys(r)?.map?.(i=>{const a=r?.[i],l=M?.menus?.find?.(p=>p?.handle===a?.handle)?.subTitle;return V(l?.[s])})})]},s)}),B=e=>{if(!r)return;const{subTitle:s,isProduct:n}=e;return n?c(T,{children:[c("div",{className:"l-tablet:flex l-tablet:flex-col specs-content-item-product box-border grid w-full cursor-pointer grid-cols-3 border-t-0 border-t-[#E4E5E6]",children:[e?.title&&t(h,{as:"h3",html:e?.title||"",className:"l:hidden specs-item-product-title"}),t("div",{className:`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:px-6 desktop:pb-6 lg-desktop:gap-16 grid-cols-${w?3:2} specs-item-product-body col-span-2 grid flex-1 pb-4 pr-0`,children:Object.keys(r)?.map((o,i)=>{const a=r?.[o],l=d?.products?.find?.(p=>p?.handle===a?.handle);return t("div",{children:U({...l,item:o,sku:a?.sku},i)},o)})})]}),e?.categoryLabel&&t(h,{size:2,as:"h4",html:e?.categoryLabel||"",className:"desktop:p-6 specs-item-product-category py-6"}),s?.length?D(s):null]}):D(s)};return te(H,()=>S.current),C(()=>{if(!d?.products?.length)return;const e=m?.sku?.split?.(",")||[],s=u&&e?.length>2?e?.slice(0,2):e;let n={};s?.forEach?.((i,a)=>{const l=d?.products?.find?.(p=>{if(p?.variants?.find?.(z=>z?.sku===i))return!0});l&&(n={...n,[a]:{sku:i,name:l?.name||l?.title,handle:l?.handle}})});const o=d?.products?.filter(i=>M?.menus?.find(a=>a?.handle===i?.handle));f(n),P(o),y(e?.length>2&&!u)},[d,u]),C(()=>{if(u){const e=Object.keys(r||{});if(e?.length>2){const s=e?.slice?.(0,2);let n={};s?.forEach?.(o=>{n={...n,[o]:r?.[o]}}),y(!1),f(n)}}},[u]),t("div",{...j,className:Z("specs-wrapper w-full overflow-hidden bg-[#F5F5F7]",F),ref:S,children:L?.data?t("div",{className:"specs-wrapper-content box-border w-full overflow-hidden",children:L?.data?.map?.((e,s)=>t("div",{className:"specs-wrapper-content-item w-full overflow-hidden pt-10 [&:first-child]:pt-0",children:B(e)},s))}):null})});E.displayName="Specs";var xe=J(E);export{xe as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/Specs/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport DropDown from './dropdown.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { useMediaQuery } from 'react-responsive'\nimport { useMemo, useState, useEffect } from 'react'\nimport { withLayout } from '../../shared/Styles.js'\nimport { formatVariantPrice } from '../ShelfDisplay/shelfDisplay.js'\nimport { Picture, Text, Button, Heading } from '../../components/index.js'\nimport { cn } from '../../helpers/index.js'\nimport React, { useImperativeHandle, useRef } from 'react'\n\nexport interface SpecsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n data?: any\n buildData?: any\n onChange?: (product: any, index: number) => void\n onSecondaryChange?: (data: any) => void\n}\n\nconst Specs = React.forwardRef<HTMLDivElement, SpecsProps>(\n ({ data, buildData, onChange, onSecondaryChange, className, ...rest }, ref) => {\n const isMobile = useMediaQuery({ query: '(max-width: 768px)' })\n\n const [active, setActive] = useState<any>({})\n const [menuList, setMenuList] = useState<any[]>([])\n const [isShowMax, setIsShowMax] = useState<boolean>(false)\n const [visibleActive, setVisibleActive] = useState<{ [key: number]: boolean }>({})\n\n const innerRef = useRef<HTMLDivElement>(null)\n\n const { locale = 'us', currencyDisplay } = useAiuiContext()\n\n const { LeftMenu, RightMenu, DefaultSelectMenu } = useMemo(() => data?.data || {}, [data?.data])\n\n const isImageUrl = (urlPath: string) => {\n try {\n const url = new URL(urlPath)\n const path = url.pathname.toLowerCase()\n return /\\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/.test(path)\n } catch (e) {\n // \u5982\u679C\u4F20\u5165\u7684\u4E0D\u662F\u6709\u6548URL\uFF08\u5982\u76F8\u5BF9\u8DEF\u5F84\uFF09\uFF0C\u76F4\u63A5\u68C0\u67E5\u8DEF\u5F84\n return /\\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/i.test(urlPath)\n }\n }\n\n const skuNode = (product: any, index: number) => {\n const findSku = product?.variants?.find?.((item: any) => item?.sku === product?.sku)\n const coupon = findSku?.coupons?.[0]\n const { price, basePrice } = formatVariantPrice({\n locale: locale || 'us',\n amount: coupon ? coupon?.variant_price4wscode : findSku?.price,\n baseAmount: coupon ? findSku?.price : 0,\n currencyDisplay,\n currencyCode: product?.price?.currencyCode || 'USD',\n })\n const buttonTextValue =\n typeof DefaultSelectMenu?.buttonText === 'string'\n ? DefaultSelectMenu?.buttonText\n : DefaultSelectMenu?.buttonText?.[String(index)] || ''\n return (\n <div className=\"specs-sku-node-wrap box-border\">\n <Text\n className={`md-tablet:p-2 l-tablet:mb-4 l-tablet:text-sm desktop:px-6 lg-desktop:mb-8 lg-desktop:text-lg openDropDown specs-sku-node-text relative mb-6 box-border block rounded-[50px] border border-[#E4E5E6] bg-[#F5F5F7] px-6 py-4 text-base font-bold`}\n onClick={() => {\n if (menuList?.length <= 1) return null\n\n setVisibleActive({\n ...visibleActive,\n [index]: !visibleActive?.[index],\n })\n }}\n >\n <div className=\"flex items-center justify-between overflow-hidden\">\n <div\n className=\"openDropDown md-tablet:text-sm lg-desktop:text-lg specs-sku-node-title flex-1 truncate text-base\"\n title={active?.[index]?.name || ''}\n >\n {active?.[index]?.name || ''}\n </div>\n {menuList?.length > 1 ? (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"25\"\n viewBox=\"0 0 24 25\"\n fill=\"none\"\n className=\"openDropDown\"\n >\n <path\n d=\"M6 9.5L12 15.5L18 9.5\"\n stroke=\"#1D1D1F\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n ) : null}\n </div>\n <DropDown\n index={index}\n list={menuList}\n active={active}\n setActive={setActive}\n visible={visibleActive}\n setVisible={setVisibleActive}\n />\n </Text>\n <div className=\"lg-desktop:max-h-[196px] lg-desktop:max-w-[196px] max-h-[138px] max-w-[138px]\">\n <Picture\n source={findSku?.image?.url || ''}\n className=\"aspect-h-[280] aspect-w-[280]\"\n imgClassName=\"w-full h-full object-cover hover:scale-105 transition-all duration-300\"\n />\n </div>\n <div className=\"lg-desktop:text-2xl mb-2 mt-6 text-xl font-bold\">\n <div className=\"lg-desktop:min-h-[32px] flex min-h-[28px] items-center\">\n {findSku?.availableForSale ? (\n <>\n <div className=\"specs-sku-node-price text-[#080A0F]\">{price || ''}</div>\n {basePrice && (\n <div className=\"lg-desktop:text-2xl specs-sku-node-base-price ml-1 text-xl text-[#86868C] line-through\">\n {basePrice}\n </div>\n )}\n </>\n ) : null}\n </div>\n </div>\n {buttonTextValue ? (\n <Button\n onClick={() => {\n onChange?.(product, index)\n }}\n className=\"specs-sku-node-button\"\n >\n {buttonTextValue}\n </Button>\n ) : null}\n </div>\n )\n }\n\n const normalNode = (v: any) => {\n if (v && typeof v !== 'string') {\n return (\n <div className=\"size-full\">\n <p\n className=\"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm\"\n dangerouslySetInnerHTML={{\n __html: v?.text || '',\n }}\n />\n <Picture\n source={v?.imgUrl}\n className=\"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]\"\n imgClassName=\"w-full h-full object-cover\"\n />\n </div>\n )\n }\n return (\n <div className=\"break-all\">\n {isImageUrl(v) ? (\n <Picture\n source={v}\n className=\"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]\"\n imgClassName=\"w-full h-full object-cover\"\n />\n ) : (\n <p\n className=\"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm\"\n dangerouslySetInnerHTML={{\n __html: v || '',\n }}\n />\n )}\n </div>\n )\n }\n\n const productNode = (data: any) => {\n return data.map((st: any, idx: number) => {\n const isFirstParameter = idx === 0\n return (\n <div\n key={st}\n className={`l-tablet:flex l-tablet:flex-col box-border grid w-full cursor-pointer grid-cols-3 overflow-hidden border-t border-t-[#E4E5E6] ${isFirstParameter ? '' : ''} specs-product-node-wrap`}\n >\n <Heading\n as=\"h3\"\n html={st || ''}\n className=\"tablet:py-6 l-tablet:text-[#86868C] desktop:p-6 lg-desktop:text-lg specs-product-node-title mr-4 flex-1 pt-4 text-base font-bold md:text-sm\"\n />\n <div\n className={`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:p-6 lg-desktop:gap-16 grid-cols-${isShowMax ? 3 : 2} specs-product-node-body col-span-2 grid flex-1 py-6`}\n >\n {Object.keys(active)?.map?.((item: string) => {\n const currentData = active?.[item]\n const currentMenus = RightMenu?.menus?.find?.(\n (item: any) => item?.handle === currentData?.handle\n )?.subTitle\n return normalNode(currentMenus?.[st])\n })}\n </div>\n </div>\n )\n })\n }\n\n // \u5DE6\u4FA7\u6807\u9898\u83DC\u5355\n const childrenNode = (node: any) => {\n if (!active) return\n const { subTitle, isProduct } = node\n // \u5982\u679C\u662F\u4EA7\u54C1\n if (isProduct) {\n return (\n <>\n <div\n className={`l-tablet:flex l-tablet:flex-col specs-content-item-product box-border grid w-full cursor-pointer grid-cols-3 border-t-0 border-t-[#E4E5E6]`}\n >\n {node?.title && (\n <Heading as=\"h3\" html={node?.title || ''} className=\"l:hidden specs-item-product-title\" />\n )}\n <div\n className={`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:px-6 desktop:pb-6 lg-desktop:gap-16 grid-cols-${isShowMax ? 3 : 2} specs-item-product-body col-span-2 grid flex-1 pb-4 pr-0`}\n >\n {Object.keys(active)?.map((item: string, index: number) => {\n const currentData = active?.[item]\n const currentProduct = buildData?.products?.find?.(\n (item: any) => item?.handle === currentData?.handle\n )\n return (\n <div key={item}>{skuNode({ ...currentProduct, item: item, sku: currentData?.sku }, index)}</div>\n )\n })}\n </div>\n </div>\n {node?.categoryLabel && (\n <Heading\n size={2}\n as=\"h4\"\n html={node?.categoryLabel || ''}\n className=\"desktop:p-6 specs-item-product-category py-6\"\n />\n )}\n {subTitle?.length ? productNode(subTitle) : null}\n </>\n )\n }\n return productNode(subTitle)\n }\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n useEffect(() => {\n if (!buildData?.products?.length) return\n const skus = DefaultSelectMenu?.sku?.split?.(',') || []\n const limitedSkus = isMobile && skus?.length > 2 ? skus?.slice(0, 2) : skus\n let currentActive = {}\n limitedSkus?.forEach?.((sku: string, index: number) => {\n const findData = buildData?.products?.find?.((item: any) => {\n const findSku = item?.variants?.find?.((v: any) => v?.sku === sku)\n if (findSku) return true\n })\n if (findData) {\n currentActive = {\n ...currentActive,\n [index]: {\n sku: sku,\n name: findData?.name || findData?.title,\n handle: findData?.handle,\n },\n }\n }\n })\n const currentMenu = buildData?.products?.filter((item: any) => {\n return RightMenu?.menus?.find((params: any) => params?.handle === item?.handle)\n })\n setActive(currentActive)\n setMenuList(currentMenu)\n setIsShowMax(skus?.length > 2 && !isMobile)\n }, [buildData, isMobile])\n\n useEffect(() => {\n if (isMobile) {\n const currentActive = Object.keys(active || {})\n if (currentActive?.length > 2) {\n const newActive = currentActive?.slice?.(0, 2)\n let newShowActive = {}\n newActive?.forEach?.((item: string) => {\n newShowActive = { ...newShowActive, [item]: active?.[item] }\n })\n setIsShowMax(false)\n setActive(newShowActive)\n }\n }\n }, [isMobile])\n\n return (\n <div {...rest} className={cn('specs-wrapper w-full overflow-hidden bg-[#F5F5F7]', className)} ref={innerRef}>\n {LeftMenu?.data ? (\n <div className=\"specs-wrapper-content box-border w-full overflow-hidden\">\n {LeftMenu?.data?.map?.((item: any, index: number) => {\n return (\n <div\n key={index}\n className=\"specs-wrapper-content-item w-full overflow-hidden pt-10 [&:first-child]:pt-0\"\n >\n {childrenNode(item)}\n </div>\n )\n })}\n </div>\n ) : null}\n </div>\n )\n }\n)\n\nSpecs.displayName = 'Specs'\n\nexport default withLayout(Specs)\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Fragment", "jsx", "jsxs", "DropDown", "useAiuiContext", "useMediaQuery", "useMemo", "useState", "useEffect", "withLayout", "formatVariantPrice", "Picture", "Text", "Button", "Heading", "cn", "React", "useImperativeHandle", "useRef", "Specs", "data", "buildData", "onChange", "onSecondaryChange", "className", "rest", "ref", "isMobile", "active", "setActive", "menuList", "setMenuList", "isShowMax", "setIsShowMax", "visibleActive", "setVisibleActive", "innerRef", "locale", "currencyDisplay", "LeftMenu", "RightMenu", "DefaultSelectMenu", "isImageUrl", "urlPath", "path", "skuNode", "product", "index", "findSku", "item", "coupon", "price", "basePrice", "buttonTextValue", "normalNode", "v", "productNode", "st", "idx", "isFirstParameter", "currentData", "currentMenus", "childrenNode", "node", "subTitle", "isProduct", "currentProduct", "skus", "limitedSkus", "currentActive", "sku", "findData", "currentMenu", "params", "newActive", "newShowActive", "Specs_default"]
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport DropDown from './dropdown.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { useMediaQuery } from 'react-responsive'\nimport { useMemo, useState, useEffect } from 'react'\nimport { withLayout } from '../../shared/Styles.js'\nimport { formatVariantPrice } from '../ShelfDisplay/shelfDisplay.js'\nimport { Picture, Text, Button, Heading } from '../../components/index.js'\nimport { cn } from '../../helpers/index.js'\nimport React, { useImperativeHandle, useRef } from 'react'\n\nexport interface SpecsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n data?: any\n buildData?: any\n onChange?: (product: any, index: number) => void\n onSecondaryChange?: (data: any) => void\n}\n\nconst Specs = React.forwardRef<HTMLDivElement, SpecsProps>(\n ({ data, buildData, onChange, onSecondaryChange, className, ...rest }, ref) => {\n const isMobile = useMediaQuery({ query: '(max-width: 768px)' })\n\n const [active, setActive] = useState<any>({})\n const [menuList, setMenuList] = useState<any[]>([])\n const [isShowMax, setIsShowMax] = useState<boolean>(false)\n const [visibleActive, setVisibleActive] = useState<{ [key: number]: boolean }>({})\n\n const innerRef = useRef<HTMLDivElement>(null)\n\n const { locale = 'us', currencyDisplay, trackingData } = useAiuiContext()\n\n /** \u662F\u5426\u663E\u793A\u539F\u4EF7\uFF08\u5212\u7EBF\u4EF7\uFF09\uFF0C\u9ED8\u8BA4\u663E\u793A */\n const showComparePrice = trackingData?.showComparePrice ?? true\n\n const { LeftMenu, RightMenu, DefaultSelectMenu } = useMemo(() => data?.data || {}, [data?.data])\n\n const isImageUrl = (urlPath: string) => {\n try {\n const url = new URL(urlPath)\n const path = url.pathname.toLowerCase()\n return /\\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/.test(path)\n } catch (e) {\n // \u5982\u679C\u4F20\u5165\u7684\u4E0D\u662F\u6709\u6548URL\uFF08\u5982\u76F8\u5BF9\u8DEF\u5F84\uFF09\uFF0C\u76F4\u63A5\u68C0\u67E5\u8DEF\u5F84\n return /\\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/i.test(urlPath)\n }\n }\n\n const skuNode = (product: any, index: number) => {\n const findSku = product?.variants?.find?.((item: any) => item?.sku === product?.sku)\n const coupon = findSku?.coupons?.[0]\n const { price, basePrice } = formatVariantPrice({\n locale: locale || 'us',\n amount: coupon ? coupon?.variant_price4wscode : findSku?.price,\n baseAmount: coupon ? findSku?.price : 0,\n currencyDisplay,\n currencyCode: product?.price?.currencyCode || 'USD',\n })\n const buttonTextValue =\n typeof DefaultSelectMenu?.buttonText === 'string'\n ? DefaultSelectMenu?.buttonText\n : DefaultSelectMenu?.buttonText?.[String(index)] || ''\n return (\n <div className=\"specs-sku-node-wrap box-border\">\n <Text\n className={`md-tablet:p-2 l-tablet:mb-4 l-tablet:text-sm desktop:px-6 lg-desktop:mb-8 lg-desktop:text-lg openDropDown specs-sku-node-text relative mb-6 box-border block rounded-[50px] border border-[#E4E5E6] bg-[#F5F5F7] px-6 py-4 text-base font-bold`}\n onClick={() => {\n if (menuList?.length <= 1) return null\n\n setVisibleActive({\n ...visibleActive,\n [index]: !visibleActive?.[index],\n })\n }}\n >\n <div className=\"flex items-center justify-between overflow-hidden\">\n <div\n className=\"openDropDown md-tablet:text-sm lg-desktop:text-lg specs-sku-node-title flex-1 truncate text-base\"\n title={active?.[index]?.name || ''}\n >\n {active?.[index]?.name || ''}\n </div>\n {menuList?.length > 1 ? (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"25\"\n viewBox=\"0 0 24 25\"\n fill=\"none\"\n className=\"openDropDown\"\n >\n <path\n d=\"M6 9.5L12 15.5L18 9.5\"\n stroke=\"#1D1D1F\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n ) : null}\n </div>\n <DropDown\n index={index}\n list={menuList}\n active={active}\n setActive={setActive}\n visible={visibleActive}\n setVisible={setVisibleActive}\n />\n </Text>\n <div className=\"lg-desktop:max-h-[196px] lg-desktop:max-w-[196px] max-h-[138px] max-w-[138px]\">\n <Picture\n source={findSku?.image?.url || ''}\n className=\"aspect-h-[280] aspect-w-[280]\"\n imgClassName=\"w-full h-full object-cover hover:scale-105 transition-all duration-300\"\n />\n </div>\n <div className=\"lg-desktop:text-2xl mb-2 mt-6 text-xl font-bold\">\n <div className=\"lg-desktop:min-h-[32px] flex min-h-[28px] items-center\">\n {findSku?.availableForSale ? (\n <>\n <div className=\"specs-sku-node-price text-[#080A0F]\">{price || ''}</div>\n {showComparePrice && basePrice && (\n <div className=\"lg-desktop:text-2xl specs-sku-node-base-price ml-1 text-xl text-[#86868C] line-through\">\n {basePrice}\n </div>\n )}\n </>\n ) : null}\n </div>\n </div>\n {buttonTextValue ? (\n <Button\n onClick={() => {\n onChange?.(product, index)\n }}\n className=\"specs-sku-node-button\"\n >\n {buttonTextValue}\n </Button>\n ) : null}\n </div>\n )\n }\n\n const normalNode = (v: any) => {\n if (v && typeof v !== 'string') {\n return (\n <div className=\"size-full\">\n <p\n className=\"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm\"\n dangerouslySetInnerHTML={{\n __html: v?.text || '',\n }}\n />\n <Picture\n source={v?.imgUrl}\n className=\"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]\"\n imgClassName=\"w-full h-full object-cover\"\n />\n </div>\n )\n }\n return (\n <div className=\"break-all\">\n {isImageUrl(v) ? (\n <Picture\n source={v}\n className=\"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]\"\n imgClassName=\"w-full h-full object-cover\"\n />\n ) : (\n <p\n className=\"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm\"\n dangerouslySetInnerHTML={{\n __html: v || '',\n }}\n />\n )}\n </div>\n )\n }\n\n const productNode = (data: any) => {\n return data.map((st: any, idx: number) => {\n const isFirstParameter = idx === 0\n return (\n <div\n key={st}\n className={`l-tablet:flex l-tablet:flex-col box-border grid w-full cursor-pointer grid-cols-3 overflow-hidden border-t border-t-[#E4E5E6] ${isFirstParameter ? '' : ''} specs-product-node-wrap`}\n >\n <Heading\n as=\"h3\"\n html={st || ''}\n className=\"tablet:py-6 l-tablet:text-[#86868C] desktop:p-6 lg-desktop:text-lg specs-product-node-title mr-4 flex-1 pt-4 text-base font-bold md:text-sm\"\n />\n <div\n className={`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:p-6 lg-desktop:gap-16 grid-cols-${isShowMax ? 3 : 2} specs-product-node-body col-span-2 grid flex-1 py-6`}\n >\n {Object.keys(active)?.map?.((item: string) => {\n const currentData = active?.[item]\n const currentMenus = RightMenu?.menus?.find?.(\n (item: any) => item?.handle === currentData?.handle\n )?.subTitle\n return normalNode(currentMenus?.[st])\n })}\n </div>\n </div>\n )\n })\n }\n\n // \u5DE6\u4FA7\u6807\u9898\u83DC\u5355\n const childrenNode = (node: any) => {\n if (!active) return\n const { subTitle, isProduct } = node\n // \u5982\u679C\u662F\u4EA7\u54C1\n if (isProduct) {\n return (\n <>\n <div\n className={`l-tablet:flex l-tablet:flex-col specs-content-item-product box-border grid w-full cursor-pointer grid-cols-3 border-t-0 border-t-[#E4E5E6]`}\n >\n {node?.title && (\n <Heading as=\"h3\" html={node?.title || ''} className=\"l:hidden specs-item-product-title\" />\n )}\n <div\n className={`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:px-6 desktop:pb-6 lg-desktop:gap-16 grid-cols-${isShowMax ? 3 : 2} specs-item-product-body col-span-2 grid flex-1 pb-4 pr-0`}\n >\n {Object.keys(active)?.map((item: string, index: number) => {\n const currentData = active?.[item]\n const currentProduct = buildData?.products?.find?.(\n (item: any) => item?.handle === currentData?.handle\n )\n return (\n <div key={item}>{skuNode({ ...currentProduct, item: item, sku: currentData?.sku }, index)}</div>\n )\n })}\n </div>\n </div>\n {node?.categoryLabel && (\n <Heading\n size={2}\n as=\"h4\"\n html={node?.categoryLabel || ''}\n className=\"desktop:p-6 specs-item-product-category py-6\"\n />\n )}\n {subTitle?.length ? productNode(subTitle) : null}\n </>\n )\n }\n return productNode(subTitle)\n }\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n useEffect(() => {\n if (!buildData?.products?.length) return\n const skus = DefaultSelectMenu?.sku?.split?.(',') || []\n const limitedSkus = isMobile && skus?.length > 2 ? skus?.slice(0, 2) : skus\n let currentActive = {}\n limitedSkus?.forEach?.((sku: string, index: number) => {\n const findData = buildData?.products?.find?.((item: any) => {\n const findSku = item?.variants?.find?.((v: any) => v?.sku === sku)\n if (findSku) return true\n })\n if (findData) {\n currentActive = {\n ...currentActive,\n [index]: {\n sku: sku,\n name: findData?.name || findData?.title,\n handle: findData?.handle,\n },\n }\n }\n })\n const currentMenu = buildData?.products?.filter((item: any) => {\n return RightMenu?.menus?.find((params: any) => params?.handle === item?.handle)\n })\n setActive(currentActive)\n setMenuList(currentMenu)\n setIsShowMax(skus?.length > 2 && !isMobile)\n }, [buildData, isMobile])\n\n useEffect(() => {\n if (isMobile) {\n const currentActive = Object.keys(active || {})\n if (currentActive?.length > 2) {\n const newActive = currentActive?.slice?.(0, 2)\n let newShowActive = {}\n newActive?.forEach?.((item: string) => {\n newShowActive = { ...newShowActive, [item]: active?.[item] }\n })\n setIsShowMax(false)\n setActive(newShowActive)\n }\n }\n }, [isMobile])\n\n return (\n <div {...rest} className={cn('specs-wrapper w-full overflow-hidden bg-[#F5F5F7]', className)} ref={innerRef}>\n {LeftMenu?.data ? (\n <div className=\"specs-wrapper-content box-border w-full overflow-hidden\">\n {LeftMenu?.data?.map?.((item: any, index: number) => {\n return (\n <div\n key={index}\n className=\"specs-wrapper-content-item w-full overflow-hidden pt-10 [&:first-child]:pt-0\"\n >\n {childrenNode(item)}\n </div>\n )\n })}\n </div>\n ) : null}\n </div>\n )\n }\n)\n\nSpecs.displayName = 'Specs'\n\nexport default withLayout(Specs)\n"],
|
|
5
|
+
"mappings": "aA2EY,OA6CI,YAAAA,EA5CF,OAAAC,EADF,QAAAC,MAAA,oBAzEZ,OAAOC,MAAc,gBACrB,OAAS,kBAAAC,MAAsB,2BAC/B,OAAS,iBAAAC,MAAqB,mBAC9B,OAAS,WAAAC,EAAS,YAAAC,EAAU,aAAAC,MAAiB,QAC7C,OAAS,cAAAC,MAAkB,yBAC3B,OAAS,sBAAAC,MAA0B,kCACnC,OAAS,WAAAC,EAAS,QAAAC,EAAM,UAAAC,EAAQ,WAAAC,MAAe,4BAC/C,OAAS,MAAAC,MAAU,yBACnB,OAAOC,IAAS,uBAAAC,GAAqB,UAAAC,OAAc,QASnD,MAAMC,EAAQH,GAAM,WAClB,CAAC,CAAE,KAAAI,EAAM,UAAAC,EAAW,SAAAC,EAAU,kBAAAC,GAAmB,UAAAC,EAAW,GAAGC,CAAK,EAAGC,IAAQ,CAC7E,MAAMC,EAAWtB,EAAc,CAAE,MAAO,oBAAqB,CAAC,EAExD,CAACuB,EAAQC,CAAS,EAAItB,EAAc,CAAC,CAAC,EACtC,CAACuB,EAAUC,CAAW,EAAIxB,EAAgB,CAAC,CAAC,EAC5C,CAACyB,EAAWC,CAAY,EAAI1B,EAAkB,EAAK,EACnD,CAAC2B,EAAeC,CAAgB,EAAI5B,EAAqC,CAAC,CAAC,EAE3E6B,EAAWlB,GAAuB,IAAI,EAEtC,CAAE,OAAAmB,EAAS,KAAM,gBAAAC,EAAiB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OAAK,GAAGwB,EAAM,UAAWV,EAAG,oDAAqDS,CAAS,EAAG,IAAKY,EAChG,SAAAK,GAAU,KACTxC,EAAC,OAAI,UAAU,0DACZ,SAAAwC,GAAU,MAAM,MAAM,CAACU,EAAWF,IAE/BhD,EAAC,OAEC,UAAU,+EAET,SAAA+D,EAAab,CAAI,GAHbF,CAIP,CAEH,EACH,EACE,KACN,CAEJ,CACF,EAEA9B,EAAM,YAAc,QAEpB,IAAO2D,GAAQrE,EAAWU,CAAK",
|
|
6
|
+
"names": ["Fragment", "jsx", "jsxs", "DropDown", "useAiuiContext", "useMediaQuery", "useMemo", "useState", "useEffect", "withLayout", "formatVariantPrice", "Picture", "Text", "Button", "Heading", "cn", "React", "useImperativeHandle", "useRef", "Specs", "data", "buildData", "onChange", "onSecondaryChange", "className", "rest", "ref", "isMobile", "active", "setActive", "menuList", "setMenuList", "isShowMax", "setIsShowMax", "visibleActive", "setVisibleActive", "innerRef", "locale", "currencyDisplay", "trackingData", "showComparePrice", "LeftMenu", "RightMenu", "DefaultSelectMenu", "isImageUrl", "urlPath", "path", "skuNode", "product", "index", "findSku", "item", "coupon", "price", "basePrice", "buttonTextValue", "normalNode", "v", "productNode", "st", "idx", "isFirstParameter", "currentData", "currentMenus", "childrenNode", "node", "subTitle", "isProduct", "currentProduct", "skus", "limitedSkus", "currentActive", "sku", "findData", "currentMenu", "params", "newActive", "newShowActive", "Specs_default"]
|
|
7
7
|
}
|
|
@@ -7,6 +7,7 @@ import { type VariantProps } from 'class-variance-authority';
|
|
|
7
7
|
*/
|
|
8
8
|
declare const Alert: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
|
|
9
9
|
variant?: "default" | "destructive" | null | undefined;
|
|
10
|
+
status?: "error" | "success" | "warning" | "info" | null | undefined;
|
|
10
11
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & {
|
|
11
12
|
/**
|
|
12
13
|
* 状态
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as s from"react";import{cva as
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as s from"react";import{cva as w}from"class-variance-authority";import{cn as o}from"../helpers/index.js";const h=w("[&>svg:first-child]:text-foreground laptop:max-w-[824px] relative w-full max-w-[358px] items-center rounded-lg border px-4 py-3 text-sm font-bold [&>:first-child]:absolute [&>svg:first-child+div]:translate-y-[-3px] [&>svg:first-child]:left-4 [&>svg:first-child]:top-2 [&>svg:first-child~*]:pl-7",{variants:{variant:{default:"bg-container-secondary-1 text-info-primary",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg:first-child]:text-destructive"},status:{info:"bg-[#626263]",success:"bg-[#D6F4DE]",warning:"bg-[#F6EAD0]",error:"bg-[#F6DBD8]"}},defaultVariants:{variant:"default",status:"info"}}),C=()=>e("svg",{className:"close absolute right-4 top-2 size-6 cursor-pointer !pl-0",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e("path",{d:"M15.3452 16.4762L12.1377 13.2687L8.92973 16.4767C8.61712 16.7893 8.11029 16.7891 7.79766 16.4765C7.48505 16.1638 7.4848 15.657 7.79741 15.3444L11.0054 12.1364L7.79791 8.92891C7.48503 8.61603 7.48503 8.10946 7.79765 7.79683C8.11015 7.48433 8.61688 7.48424 8.92973 7.79709L12.1372 11.0046L15.3452 7.79658C15.6577 7.48408 16.1646 7.48421 16.4772 7.79683C16.7899 8.10946 16.79 8.61641 16.4775 8.9289L13.2695 12.1369L16.477 15.3444C16.7899 15.6572 16.7898 16.1639 16.4773 16.4764C16.1647 16.789 15.6581 16.789 15.3452 16.4762L15.3452 16.4762Z",fill:"#1D1D1F"})}),x={info:r("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("circle",{cx:"12",cy:"12",r:"10.5",fill:"#00BEFA"}),e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13.1249 7.13281C13.1249 6.51149 12.6213 6.00781 11.9999 6.00781C11.3786 6.00781 10.8749 6.51149 10.8749 7.13281V13.1328C10.8749 13.7541 11.3786 14.2578 11.9999 14.2578C12.6213 14.2578 13.1249 13.7541 13.1249 13.1328V7.13281ZM13.3499 16.6342C13.3499 15.8886 12.7455 15.2842 11.9999 15.2842C11.2543 15.2842 10.6499 15.8886 10.6499 16.6342C10.6499 17.3798 11.2543 17.9842 11.9999 17.9842C12.7455 17.9842 13.3499 17.3798 13.3499 16.6342Z",fill:"white"})]}),success:r("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("circle",{cx:"12.5",cy:"12.5",r:"10.5",fill:"#30D158"}),e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.3976 8.6772C18.0468 8.32635 17.478 8.32635 17.1271 8.6772L11.5586 14.2457L8.15843 10.8456C7.80758 10.4947 7.23874 10.4947 6.88789 10.8456C6.53704 11.1964 6.53704 11.7653 6.88789 12.1161L10.849 16.0772C10.8632 16.0914 10.8778 16.1051 10.8928 16.1182C10.9028 16.1293 10.9132 16.1402 10.9239 16.1509C11.2748 16.5018 11.8436 16.5018 12.1945 16.1509L18.3976 9.94773C18.7485 9.59688 18.7485 9.02805 18.3976 8.6772Z",fill:"white"})]}),warning:r("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("circle",{cx:"12",cy:"12",r:"10.5",fill:"#FFC24D"}),e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13.1249 7.13281C13.1249 6.51149 12.6213 6.00781 11.9999 6.00781C11.3786 6.00781 10.8749 6.51149 10.8749 7.13281V13.1328C10.8749 13.7541 11.3786 14.2578 11.9999 14.2578C12.6213 14.2578 13.1249 13.7541 13.1249 13.1328V7.13281ZM13.3499 16.6342C13.3499 15.8886 12.7455 15.2842 11.9999 15.2842C11.2543 15.2842 10.6499 15.8886 10.6499 16.6342C10.6499 17.3798 11.2543 17.9842 11.9999 17.9842C12.7455 17.9842 13.3499 17.3798 13.3499 16.6342Z",fill:"white"})]}),error:r("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("circle",{cx:"12",cy:"12",r:"10.5",fill:"#FF4D4D"}),e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13.1249 7.13281C13.1249 6.51149 12.6213 6.00781 11.9999 6.00781C11.3786 6.00781 10.8749 6.51149 10.8749 7.13281V13.1328C10.8749 13.7541 11.3786 14.2578 11.9999 14.2578C12.6213 14.2578 13.1249 13.7541 13.1249 13.1328V7.13281ZM13.3499 16.6342C13.3499 15.8886 12.7455 15.2842 11.9999 15.2842C11.2543 15.2842 10.6499 15.8886 10.6499 16.6342C10.6499 17.3798 11.2543 17.9842 11.9999 17.9842C12.7455 17.9842 13.3499 17.3798 13.3499 16.6342Z",fill:"white"})]})},a=s.forwardRef(({className:l,variant:i,status:t,closable:d=!1,children:f,...g},p)=>{const v=t?x[t]:null;return r("div",{ref:p,role:"alert",className:o(h({variant:i,status:t}),l),...g,children:[v,f,d&&e(C,{})]})});a.displayName="Alert";const n=s.forwardRef(({className:l,...i},t)=>e("h5",{ref:t,className:o("mb-1 font-bold leading-none tracking-tight",l),...i}));n.displayName="AlertTitle";const c=s.forwardRef(({className:l,...i},t)=>e("p",{ref:t,className:o("lg-desktop:text-[18px] desktop:text-[16px] text-[14px] leading-[140%]",l),...i}));c.displayName="AlertDescription";export{a as Alert,c as AlertDescription,n as AlertTitle};
|
|
2
2
|
//# sourceMappingURL=alert.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/alert.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../helpers/index.js'\n\nconst alertVariants = cva(\n '[&>svg:first-child]:text-foreground relative w-full rounded-lg border px-4 py-3 text-sm [&>:first-child]:absolute [&>svg:first-child+div]:translate-y-[-3px] [&>svg:first-child]:left-4 [&>svg:first-child]:top-2 [&>svg:first-child~*]:pl-7',\n {\n variants: {\n variant: {\n default: 'bg-
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import * as React from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../helpers/index.js'\n\nconst alertVariants = cva(\n '[&>svg:first-child]:text-foreground laptop:max-w-[824px] relative w-full max-w-[358px] items-center rounded-lg border px-4 py-3 text-sm font-bold [&>:first-child]:absolute [&>svg:first-child+div]:translate-y-[-3px] [&>svg:first-child]:left-4 [&>svg:first-child]:top-2 [&>svg:first-child~*]:pl-7',\n {\n variants: {\n variant: {\n default: 'bg-container-secondary-1 text-info-primary',\n destructive:\n 'border-destructive/50 text-destructive dark:border-destructive [&>svg:first-child]:text-destructive',\n },\n status: {\n info: 'bg-[#626263]',\n success: 'bg-[#D6F4DE]',\n warning: 'bg-[#F6EAD0]',\n error: 'bg-[#F6DBD8]',\n },\n },\n defaultVariants: {\n variant: 'default',\n status: 'info',\n },\n }\n)\n\nconst Close = () => (\n <svg\n className=\"close absolute right-4 top-2 size-6 cursor-pointer !pl-0\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M15.3452 16.4762L12.1377 13.2687L8.92973 16.4767C8.61712 16.7893 8.11029 16.7891 7.79766 16.4765C7.48505 16.1638 7.4848 15.657 7.79741 15.3444L11.0054 12.1364L7.79791 8.92891C7.48503 8.61603 7.48503 8.10946 7.79765 7.79683C8.11015 7.48433 8.61688 7.48424 8.92973 7.79709L12.1372 11.0046L15.3452 7.79658C15.6577 7.48408 16.1646 7.48421 16.4772 7.79683C16.7899 8.10946 16.79 8.61641 16.4775 8.9289L13.2695 12.1369L16.477 15.3444C16.7899 15.6572 16.7898 16.1639 16.4773 16.4764C16.1647 16.789 15.6581 16.789 15.3452 16.4762L15.3452 16.4762Z\"\n fill=\"#1D1D1F\"\n />\n </svg>\n)\n\nconst IconMap = {\n info: (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"10.5\" fill=\"#00BEFA\" />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M13.1249 7.13281C13.1249 6.51149 12.6213 6.00781 11.9999 6.00781C11.3786 6.00781 10.8749 6.51149 10.8749 7.13281V13.1328C10.8749 13.7541 11.3786 14.2578 11.9999 14.2578C12.6213 14.2578 13.1249 13.7541 13.1249 13.1328V7.13281ZM13.3499 16.6342C13.3499 15.8886 12.7455 15.2842 11.9999 15.2842C11.2543 15.2842 10.6499 15.8886 10.6499 16.6342C10.6499 17.3798 11.2543 17.9842 11.9999 17.9842C12.7455 17.9842 13.3499 17.3798 13.3499 16.6342Z\"\n fill=\"white\"\n />\n </svg>\n ),\n success: (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12.5\" cy=\"12.5\" r=\"10.5\" fill=\"#30D158\" />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M18.3976 8.6772C18.0468 8.32635 17.478 8.32635 17.1271 8.6772L11.5586 14.2457L8.15843 10.8456C7.80758 10.4947 7.23874 10.4947 6.88789 10.8456C6.53704 11.1964 6.53704 11.7653 6.88789 12.1161L10.849 16.0772C10.8632 16.0914 10.8778 16.1051 10.8928 16.1182C10.9028 16.1293 10.9132 16.1402 10.9239 16.1509C11.2748 16.5018 11.8436 16.5018 12.1945 16.1509L18.3976 9.94773C18.7485 9.59688 18.7485 9.02805 18.3976 8.6772Z\"\n fill=\"white\"\n />\n </svg>\n ),\n warning: (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"10.5\" fill=\"#FFC24D\" />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M13.1249 7.13281C13.1249 6.51149 12.6213 6.00781 11.9999 6.00781C11.3786 6.00781 10.8749 6.51149 10.8749 7.13281V13.1328C10.8749 13.7541 11.3786 14.2578 11.9999 14.2578C12.6213 14.2578 13.1249 13.7541 13.1249 13.1328V7.13281ZM13.3499 16.6342C13.3499 15.8886 12.7455 15.2842 11.9999 15.2842C11.2543 15.2842 10.6499 15.8886 10.6499 16.6342C10.6499 17.3798 11.2543 17.9842 11.9999 17.9842C12.7455 17.9842 13.3499 17.3798 13.3499 16.6342Z\"\n fill=\"white\"\n />\n </svg>\n ),\n error: (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"10.5\" fill=\"#FF4D4D\" />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M13.1249 7.13281C13.1249 6.51149 12.6213 6.00781 11.9999 6.00781C11.3786 6.00781 10.8749 6.51149 10.8749 7.13281V13.1328C10.8749 13.7541 11.3786 14.2578 11.9999 14.2578C12.6213 14.2578 13.1249 13.7541 13.1249 13.1328V7.13281ZM13.3499 16.6342C13.3499 15.8886 12.7455 15.2842 11.9999 15.2842C11.2543 15.2842 10.6499 15.8886 10.6499 16.6342C10.6499 17.3798 11.2543 17.9842 11.9999 17.9842C12.7455 17.9842 13.3499 17.3798 13.3499 16.6342Z\"\n fill=\"white\"\n />\n </svg>\n ),\n}\n\n/**\n * Alert - \u8B66\u544A\u63D0\u793A\n *\n * @description \u7528\u4E8E\u663E\u793A\u91CD\u8981\u7684\u8B66\u544A\u6216\u4FE1\u606F\u63D0\u793A\uFF0C\u652F\u6301\u591A\u79CD\u72B6\u6001\u548C\u53EF\u5173\u95ED\u529F\u80FD\n */\nconst Alert = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement> &\n VariantProps<typeof alertVariants> & {\n /**\n * \u72B6\u6001\n */\n status?: 'success' | 'error' | 'warning' | 'info'\n /**\n * \u662F\u5426\u53EF\u4EE5\u5173\u95ED\n */\n closable?: boolean\n }\n>(({ className, variant, status, closable = false, children, ...props }, ref) => {\n const icon = status ? IconMap[status] : null\n\n return (\n <div ref={ref} role=\"alert\" className={cn(alertVariants({ variant, status }), className)} {...props}>\n {icon}\n {children}\n {closable && <Close />}\n </div>\n )\n})\nAlert.displayName = 'Alert'\n\nconst AlertTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(\n ({ className, ...props }, ref) => (\n <h5 ref={ref} className={cn('mb-1 font-bold leading-none tracking-tight', className)} {...props} />\n )\n)\nAlertTitle.displayName = 'AlertTitle'\n\nconst AlertDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(\n ({ className, ...props }, ref) => (\n <p\n ref={ref}\n className={cn('lg-desktop:text-[18px] desktop:text-[16px] text-[14px] leading-[140%]', className)}\n {...props}\n />\n )\n)\nAlertDescription.displayName = 'AlertDescription'\n\nexport { Alert, AlertTitle, AlertDescription }\n"],
|
|
5
|
+
"mappings": "AAoCI,cAAAA,EASA,QAAAC,MATA,oBApCJ,UAAYC,MAAW,QACvB,OAAS,OAAAC,MAA8B,2BACvC,OAAS,MAAAC,MAAU,sBAEnB,MAAMC,EAAgBF,EACpB,ySACA,CACE,SAAU,CACR,QAAS,CACP,QAAS,6CACT,YACE,qGACJ,EACA,OAAQ,CACN,KAAM,eACN,QAAS,eACT,QAAS,eACT,MAAO,cACT,CACF,EACA,gBAAiB,CACf,QAAS,UACT,OAAQ,MACV,CACF,CACF,EAEMG,EAAQ,IACZN,EAAC,OACC,UAAU,2DACV,MAAM,KACN,OAAO,KACP,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WX,EAAGC,EAAc,CAAE,QAAAK,EAAS,OAAAC,CAAO,CAAC,EAAGF,CAAS,EAAI,GAAGK,EAC3F,UAAAE,EACAH,EACAD,GAAYZ,EAACM,EAAA,EAAM,GACtB,CAEJ,CAAC,EACDE,EAAM,YAAc,QAEpB,MAAMS,EAAaf,EAAM,WACvB,CAAC,CAAE,UAAAO,EAAW,GAAGK,CAAM,EAAGC,IACxBf,EAAC,MAAG,IAAKe,EAAK,UAAWX,EAAG,6CAA8CK,CAAS,EAAI,GAAGK,EAAO,CAErG,EACAG,EAAW,YAAc,aAEzB,MAAMC,EAAmBhB,EAAM,WAC7B,CAAC,CAAE,UAAAO,EAAW,GAAGK,CAAM,EAAGC,IACxBf,EAAC,KACC,IAAKe,EACL,UAAWX,EAAG,wEAAyEK,CAAS,EAC/F,GAAGK,EACN,CAEJ,EACAI,EAAiB,YAAc",
|
|
6
6
|
"names": ["jsx", "jsxs", "React", "cva", "cn", "alertVariants", "Close", "IconMap", "Alert", "className", "variant", "status", "closable", "children", "props", "ref", "icon", "AlertTitle", "AlertDescription"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import*as
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import*as f from"react";import*as t from"@radix-ui/react-checkbox";import{cn as i}from"../helpers/index.js";import{cva as l}from"class-variance-authority";const b=o=>e("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o,children:e("path",{d:"M7.5 15.8333L1.66667 10L3.75 7.91667L7.5 11.6667L16.25 3L18.3333 5.08333L7.5 15.8333Z",fill:"currentColor"})}),d=l("border-info-primary ring-offset-background focus-visible:ring-ring data-[state=checked]:bg-info-primary disabled:bg-btn-primary-disabled data-[state=checked]:text-info-white peer shrink-0 rounded-sm border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",{variants:{size:{sm:"size-[14px]",base:"size-4",lg:"size-5"}},defaultVariants:{size:"base"}}),r=f.forwardRef(({className:o,size:s,iconClassName:a,...c},n)=>e(t.Root,{ref:n,className:i(d({size:s}),o),...c,children:e(t.Indicator,{className:i("flex size-full items-center justify-center text-current"),children:e(b,{width:16,height:12,className:a})})}));r.displayName="Checkbox";var h=r;export{h as default};
|
|
2
2
|
//# sourceMappingURL=checkbox.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/checkbox.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox'\n// import { CheckIcon } from '@radix-ui/react-icons'\n\nimport { cn } from '../helpers/index.js'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nconst CheckIcon = (props: React.SVGProps<SVGSVGElement>) => {\n return (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M7.5 15.8333L1.66667 10L3.75 7.91667L7.5 11.6667L16.25 3L18.3333 5.08333L7.5 15.8333Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nconst checkboxVariants = cva(\n 'border-primary ring-offset-background focus-visible:ring-ring data-[state=checked]:bg-
|
|
5
|
-
"mappings": "aAYM,cAAAA,MAAA,oBAVN,UAAYC,MAAW,QACvB,UAAYC,MAAuB,2BAGnC,OAAS,MAAAC,MAAU,sBACnB,OAAS,OAAAC,MAA8B,2BAEvC,MAAMC,EAAaC,GAEfN,EAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAA8B,GAAGM,EACjG,SAAAN,EAAC,QACC,EAAE,wFACF,KAAK,eACP,EACF,EAIEO,EAAmBH,EACvB,
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox'\n// import { CheckIcon } from '@radix-ui/react-icons'\n\nimport { cn } from '../helpers/index.js'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nconst CheckIcon = (props: React.SVGProps<SVGSVGElement>) => {\n return (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M7.5 15.8333L1.66667 10L3.75 7.91667L7.5 11.6667L16.25 3L18.3333 5.08333L7.5 15.8333Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nconst checkboxVariants = cva(\n 'border-info-primary ring-offset-background focus-visible:ring-ring data-[state=checked]:bg-info-primary disabled:bg-btn-primary-disabled data-[state=checked]:text-info-white peer shrink-0 rounded-sm border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',\n {\n variants: {\n size: {\n sm: 'size-[14px]',\n base: 'size-4',\n lg: 'size-5',\n },\n },\n defaultVariants: {\n size: 'base',\n },\n }\n)\n\ninterface CheckboxProps\n extends React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, VariantProps<typeof checkboxVariants> {\n iconClassName?: string\n}\n\n/**\n * Checkbox - \u590D\u9009\u6846\n *\n * @description \u5141\u8BB8\u7528\u6237\u8FDB\u884C\u591A\u9009\u64CD\u4F5C\u7684\u590D\u9009\u6846\u7EC4\u4EF6\uFF0C\u652F\u6301\u4E0D\u540C\u5C3A\u5BF8\u548C\u81EA\u5B9A\u4E49\u56FE\u6807\n */\nconst Checkbox = React.forwardRef<React.ElementRef<typeof CheckboxPrimitive.Root>, CheckboxProps>(\n ({ className, size, iconClassName, ...props }, ref) => (\n <CheckboxPrimitive.Root ref={ref} className={cn(checkboxVariants({ size }), className)} {...props}>\n <CheckboxPrimitive.Indicator className={cn('flex size-full items-center justify-center text-current')}>\n <CheckIcon width={16} height={12} className={iconClassName} />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n )\n)\nCheckbox.displayName = 'Checkbox'\n\nexport default Checkbox\nexport type { CheckboxProps }\n"],
|
|
5
|
+
"mappings": "aAYM,cAAAA,MAAA,oBAVN,UAAYC,MAAW,QACvB,UAAYC,MAAuB,2BAGnC,OAAS,MAAAC,MAAU,sBACnB,OAAS,OAAAC,MAA8B,2BAEvC,MAAMC,EAAaC,GAEfN,EAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAA8B,GAAGM,EACjG,SAAAN,EAAC,QACC,EAAE,wFACF,KAAK,eACP,EACF,EAIEO,EAAmBH,EACvB,4UACA,CACE,SAAU,CACR,KAAM,CACJ,GAAI,cACJ,KAAM,SACN,GAAI,QACN,CACF,EACA,gBAAiB,CACf,KAAM,MACR,CACF,CACF,EAYMI,EAAWP,EAAM,WACrB,CAAC,CAAE,UAAAQ,EAAW,KAAAC,EAAM,cAAAC,EAAe,GAAGL,CAAM,EAAGM,IAC7CZ,EAACE,EAAkB,KAAlB,CAAuB,IAAKU,EAAK,UAAWT,EAAGI,EAAiB,CAAE,KAAAG,CAAK,CAAC,EAAGD,CAAS,EAAI,GAAGH,EAC1F,SAAAN,EAACE,EAAkB,UAAlB,CAA4B,UAAWC,EAAG,yDAAyD,EAClG,SAAAH,EAACK,EAAA,CAAU,MAAO,GAAI,OAAQ,GAAI,UAAWM,EAAe,EAC9D,EACF,CAEJ,EACAH,EAAS,YAAc,WAEvB,IAAOK,EAAQL",
|
|
6
6
|
"names": ["jsx", "React", "CheckboxPrimitive", "cn", "cva", "CheckIcon", "props", "checkboxVariants", "Checkbox", "className", "size", "iconClassName", "ref", "checkbox_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as o,jsxs as r}from"react/jsx-runtime";import*as s from"react";import*as
|
|
1
|
+
"use client";import{jsx as o,jsxs as r}from"react/jsx-runtime";import*as s from"react";import*as t from"@radix-ui/react-dialog";import{cn as l}from"../helpers/index.js";const u=e=>o("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:o("path",{d:"M5.63657 5.63618C6.02704 5.2456 6.66026 5.24565 7.05079 5.63618L12.0005 10.5859L16.9503 5.63618C17.3408 5.24565 17.974 5.2456 18.3645 5.63618C18.7549 6.02672 18.7549 6.65986 18.3645 7.05039L13.4147 12.0001L18.3645 16.9499C18.7549 17.3404 18.7549 17.9736 18.3645 18.3641C17.974 18.7547 17.3408 18.7546 16.9503 18.3641L12.0005 13.4144L7.05079 18.3641C6.66026 18.7546 6.02704 18.7547 5.63657 18.3641C5.24614 17.9736 5.24615 17.3404 5.63657 16.9499L10.5863 12.0001L5.63657 7.05039C5.24615 6.65986 5.24614 6.02672 5.63657 5.63618Z",fill:"#4A4C56"})}),d=t.Root;d.displayName="Dialog";const C=t.Trigger,c=t.Portal,R=t.Close,n=s.forwardRef(({className:e,...a},i)=>o(t.Overlay,{ref:i,className:l("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1000] bg-black/80",e),...a}));n.displayName=t.Overlay.displayName;const m=s.forwardRef(({className:e,children:a,overlayClassName:i,...y},v)=>r(c,{children:[o(n,{className:i}),r(t.Content,{ref:v,className:l("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] tablet:rounded-lg fixed left-1/2 top-1/2 z-[1001] grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border p-6 shadow-lg duration-200",e),...y,children:[a,r(t.Close,{className:"dialog-close-button ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 disabled:pointer-events-none",children:[o(u,{className:"dialog-close-icon tablet:size-6 size-4"}),o("span",{className:"sr-only",children:"Close"})]})]})]}));m.displayName=t.Content.displayName;const p=({className:e,...a})=>o("div",{className:l("tablet:text-left flex flex-col space-y-1.5 text-center",e),...a});p.displayName="DialogHeader";const g=({className:e,...a})=>o("div",{className:l("tablet:flex-row tablet:justify-end tablet:space-x-2 flex flex-col-reverse",e),...a});g.displayName="DialogFooter";const f=s.forwardRef(({className:e,...a},i)=>o(t.Title,{ref:i,className:l("text-lg font-semibold leading-none tracking-tight",e),...a}));f.displayName=t.Title.displayName;const D=s.forwardRef(({className:e,...a},i)=>o(t.Description,{ref:i,className:l("text-muted-foreground text-sm",e),...a}));D.displayName=t.Description.displayName;export{d as Dialog,R as DialogClose,m as DialogContent,D as DialogDescription,g as DialogFooter,p as DialogHeader,n as DialogOverlay,c as DialogPortal,f as DialogTitle,C as DialogTrigger};
|
|
2
2
|
//# sourceMappingURL=dialog.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dialog.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\nimport {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "React", "DialogPrimitive", "Cross2Icon", "
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\n\nimport { cn } from '../helpers/index.js'\n\nconst Cross2Icon = (props: React.ComponentPropsWithoutRef<'svg'>) => (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M5.63657 5.63618C6.02704 5.2456 6.66026 5.24565 7.05079 5.63618L12.0005 10.5859L16.9503 5.63618C17.3408 5.24565 17.974 5.2456 18.3645 5.63618C18.7549 6.02672 18.7549 6.65986 18.3645 7.05039L13.4147 12.0001L18.3645 16.9499C18.7549 17.3404 18.7549 17.9736 18.3645 18.3641C17.974 18.7547 17.3408 18.7546 16.9503 18.3641L12.0005 13.4144L7.05079 18.3641C6.66026 18.7546 6.02704 18.7547 5.63657 18.3641C5.24614 17.9736 5.24615 17.3404 5.63657 16.9499L10.5863 12.0001L5.63657 7.05039C5.24615 6.65986 5.24614 6.02672 5.63657 5.63618Z\"\n fill=\"#4A4C56\"\n />\n </svg>\n)\n\nconst Dialog = DialogPrimitive.Root\nDialog.displayName = 'Dialog'\n\nconst DialogTrigger = DialogPrimitive.Trigger\n\nconst DialogPortal = DialogPrimitive.Portal\n\nconst DialogClose = DialogPrimitive.Close\n\ntype OverlayProps = DialogPrimitive.DialogOverlayProps & React.HTMLAttributes<HTMLDivElement>\n\nconst DialogOverlay = React.forwardRef<HTMLDivElement, OverlayProps>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1000] bg-black/80',\n className\n )}\n {...props}\n />\n))\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {\n overlayClassName?: string\n }\n>(({ className, children, overlayClassName, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay className={overlayClassName} />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n 'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] tablet:rounded-lg fixed left-1/2 top-1/2 z-[1001] grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border p-6 shadow-lg duration-200',\n className\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"dialog-close-button ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 disabled:pointer-events-none\">\n <Cross2Icon className=\"dialog-close-icon tablet:size-6 size-4\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n))\nDialogContent.displayName = DialogPrimitive.Content.displayName\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn('tablet:text-left flex flex-col space-y-1.5 text-center', className)} {...props} />\n)\nDialogHeader.displayName = 'DialogHeader'\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn('tablet:flex-row tablet:justify-end tablet:space-x-2 flex flex-col-reverse', className)}\n {...props}\n />\n)\nDialogFooter.displayName = 'DialogFooter'\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold leading-none tracking-tight', className)}\n {...props}\n />\n))\nDialogTitle.displayName = DialogPrimitive.Title.displayName\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description ref={ref} className={cn('text-muted-foreground text-sm', className)} {...props} />\n))\nDialogDescription.displayName = DialogPrimitive.Description.displayName\n\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogClose,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n}\n"],
|
|
5
|
+
"mappings": "aASI,cAAAA,EA+CE,QAAAC,MA/CF,oBAPJ,UAAYC,MAAW,QACvB,UAAYC,MAAqB,yBAEjC,OAAS,MAAAC,MAAU,sBAEnB,MAAMC,EAAcC,GAClBN,EAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAA8B,GAAGM,EACjG,SAAAN,EAAC,QACC,EAAE,ghBACF,KAAK,UACP,EACF,EAGIO,EAASJ,EAAgB,KAC/BI,EAAO,YAAc,SAErB,MAAMC,EAAgBL,EAAgB,QAEhCM,EAAeN,EAAgB,OAE/BO,EAAcP,EAAgB,MAI9BQ,EAAgBT,EAAM,WAAyC,CAAC,CAAE,UAAAU,EAAW,GAAGN,CAAM,EAAGO,IAC7Fb,EAACG,EAAgB,QAAhB,CACC,IAAKU,EACL,UAAWT,EACT,8JACAQ,CACF,EACC,GAAGN,EACN,CACD,EACDK,EAAc,YAAcR,EAAgB,QAAQ,YAEpD,MAAMW,EAAgBZ,EAAM,WAK1B,CAAC,CAAE,UAAAU,EAAW,SAAAG,EAAU,iBAAAC,EAAkB,GAAGV,CAAM,EAAGO,IACtDZ,EAACQ,EAAA,CACC,UAAAT,EAACW,EAAA,CAAc,UAAWK,EAAkB,EAC5Cf,EAACE,EAAgB,QAAhB,CACC,IAAKU,EACL,UAAWT,EACT,8fACAQ,CACF,EACC,GAAGN,EAEH,UAAAS,EACDd,EAACE,EAAgB,MAAhB,CAAsB,UAAU,gPAC/B,UAAAH,EAACK,EAAA,CAAW,UAAU,yCAAyC,EAC/DL,EAAC,QAAK,UAAU,UAAU,iBAAK,GACjC,GACF,GACF,CACD,EACDc,EAAc,YAAcX,EAAgB,QAAQ,YAEpD,MAAMc,EAAe,CAAC,CAAE,UAAAL,EAAW,GAAGN,CAAM,IAC1CN,EAAC,OAAI,UAAWI,EAAG,yDAA0DQ,CAAS,EAAI,GAAGN,EAAO,EAEtGW,EAAa,YAAc,eAE3B,MAAMC,EAAe,CAAC,CAAE,UAAAN,EAAW,GAAGN,CAAM,IAC1CN,EAAC,OACC,UAAWI,EAAG,4EAA6EQ,CAAS,EACnG,GAAGN,EACN,EAEFY,EAAa,YAAc,eAE3B,MAAMC,EAAcjB,EAAM,WAGxB,CAAC,CAAE,UAAAU,EAAW,GAAGN,CAAM,EAAGO,IAC1Bb,EAACG,EAAgB,MAAhB,CACC,IAAKU,EACL,UAAWT,EAAG,oDAAqDQ,CAAS,EAC3E,GAAGN,EACN,CACD,EACDa,EAAY,YAAchB,EAAgB,MAAM,YAEhD,MAAMiB,EAAoBlB,EAAM,WAG9B,CAAC,CAAE,UAAAU,EAAW,GAAGN,CAAM,EAAGO,IAC1Bb,EAACG,EAAgB,YAAhB,CAA4B,IAAKU,EAAK,UAAWT,EAAG,gCAAiCQ,CAAS,EAAI,GAAGN,EAAO,CAC9G,EACDc,EAAkB,YAAcjB,EAAgB,YAAY",
|
|
6
|
+
"names": ["jsx", "jsxs", "React", "DialogPrimitive", "cn", "Cross2Icon", "props", "Dialog", "DialogTrigger", "DialogPortal", "DialogClose", "DialogOverlay", "className", "ref", "DialogContent", "children", "overlayClassName", "DialogHeader", "DialogFooter", "DialogTitle", "DialogDescription"]
|
|
7
7
|
}
|
|
@@ -28,3 +28,4 @@ export { default as LoadingDots } from './loadingDots.js';
|
|
|
28
28
|
export { ExposureDetector, type ExposureDetectorProps } from './ExposureDetector.js';
|
|
29
29
|
export { default as BrandStrip } from './brand-strip.js';
|
|
30
30
|
export { default as Progress, type ProgressProps, type ProgressClassNames } from './progress.js';
|
|
31
|
+
export { default as OtpInput, type OtpInputProps } from './otp-input.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{default as e}from"./button.js";import{default as
|
|
1
|
+
import{default as e}from"./button.js";import{default as p}from"./badge.js";import{Input as n,InputSlot as u}from"./input.js";import{default as d}from"./checkbox.js";import{default as i}from"./skeleton.js";import{Dialog as m,DialogPortal as D,DialogOverlay as x,DialogClose as C,DialogTrigger as g,DialogContent as w,DialogHeader as P,DialogFooter as y,DialogTitle as T,DialogDescription as I}from"./dialog.js";import{Popover as b,PopoverTrigger as c,PopoverContent as G}from"./popover.js";import{RadioGroup as S,RadioGroupItem as A}from"./radio.js";import{Text as R}from"./text.js";import{Grid as L,GridItem as h}from"./grid.js";import{Heading as F}from"./heading.js";import{Container as O}from"./container.js";import{Color as j}from"./color.js";import{Drawer as z,DrawerPortal as J,DrawerOverlay as K,DrawerTrigger as Q,DrawerClose as U,DrawerContent as V,DrawerHeader as W,DrawerFooter as X,DrawerTitle as Y,DrawerDescription as Z}from"./drawer.js";import{default as $}from"./link.js";import{Avatar as or,AvatarImage as er,AvatarFallback as tr}from"./avatar.js";import{default as ar}from"./input-number.js";import{DropdownMenu as ur,DropdownMenuTrigger as sr,DropdownMenuContent as dr,DropdownMenuItem as lr,DropdownMenuCheckboxItem as ir,DropdownMenuRadioItem as fr,DropdownMenuLabel as mr,DropdownMenuSeparator as Dr,DropdownMenuShortcut as xr,DropdownMenuGroup as Cr,DropdownMenuPortal as gr,DropdownMenuSub as wr,DropdownMenuSubContent as Pr,DropdownMenuSubTrigger as yr,DropdownMenuRadioGroup as Tr}from"./drop-down.js";import{Card as Mr,CardHeader as br,CardFooter as cr,CardTitle as Gr,CardDescription as vr,CardContent as Sr}from"./card.js";import{default as kr}from"./Countdown.js";import{Carousel as Hr,CarouselContent as Lr,CarouselItem as hr,CarouselPrevious as Br,CarouselNext as Fr}from"./carousel.js";import{Tabs as Or,TabsList as Er,TabsTrigger as jr,TabsContent as qr}from"./tabs.js";import{Alert as Jr,AlertTitle as Kr,AlertDescription as Qr}from"./alert.js";import{default as Vr}from"./picture.js";import{default as Xr}from"./theme.js";import{default as Zr}from"./board.js";import{default as $r}from"./loadingDots.js";import{ExposureDetector as oo}from"./ExposureDetector.js";import{default as to}from"./brand-strip.js";import{default as ao}from"./progress.js";import{default as uo}from"./otp-input.js";export{Jr as Alert,Qr as AlertDescription,Kr as AlertTitle,or as Avatar,tr as AvatarFallback,er as AvatarImage,p as Badge,Zr as Board,to as BrandStrip,e as Button,Mr as Card,Sr as CardContent,vr as CardDescription,cr as CardFooter,br as CardHeader,Gr as CardTitle,Hr as Carousel,Lr as CarouselContent,hr as CarouselItem,Fr as CarouselNext,Br as CarouselPrevious,d as Checkbox,j as Color,O as Container,kr as Countdown,m as Dialog,C as DialogClose,w as DialogContent,I as DialogDescription,y as DialogFooter,P as DialogHeader,x as DialogOverlay,D as DialogPortal,T as DialogTitle,g as DialogTrigger,z as Drawer,U as DrawerClose,V as DrawerContent,Z as DrawerDescription,X as DrawerFooter,W as DrawerHeader,K as DrawerOverlay,J as DrawerPortal,Y as DrawerTitle,Q as DrawerTrigger,ur as DropdownMenu,ir as DropdownMenuCheckboxItem,dr as DropdownMenuContent,Cr as DropdownMenuGroup,lr as DropdownMenuItem,mr as DropdownMenuLabel,gr as DropdownMenuPortal,Tr as DropdownMenuRadioGroup,fr as DropdownMenuRadioItem,Dr as DropdownMenuSeparator,xr as DropdownMenuShortcut,wr as DropdownMenuSub,Pr as DropdownMenuSubContent,yr as DropdownMenuSubTrigger,sr as DropdownMenuTrigger,oo as ExposureDetector,L as Grid,h as GridItem,F as Heading,n as Input,ar as InputNumber,u as InputSlot,$ as Link,$r as LoadingDots,uo as OtpInput,Vr as Picture,b as Popover,G as PopoverContent,c as PopoverTrigger,ao as Progress,S as RadioGroup,A as RadioGroupItem,i as Skeleton,Or as Tabs,qr as TabsContent,Er as TabsList,jr as TabsTrigger,R as Text,Xr as Theme};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { default as Button } from './button.js'\nexport { default as Badge } from './badge.js'\nexport { Input, InputSlot } from './input.js'\n\nexport { default as Checkbox } from './checkbox.js'\n\nexport { default as Skeleton } from './skeleton.js'\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogClose,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n} from './dialog.js'\nexport { Popover, PopoverTrigger, PopoverContent } from './popover.js'\nexport { RadioGroup, RadioGroupItem, type RadioGroupProps, type RadioGroupItemProps } from './radio.js'\nexport { Text, type TextProps } from './text.js'\nexport { Grid, GridItem, type GridProps, type GridItemProps } from './grid.js'\nexport { Heading, type HeadingProps } from './heading.js'\nexport { Container, type ContainerProps } from './container.js'\nexport { Color, type ColorProps } from './color.js'\nexport {\n Drawer,\n DrawerPortal,\n DrawerOverlay,\n DrawerTrigger,\n DrawerClose,\n DrawerContent,\n DrawerHeader,\n DrawerFooter,\n DrawerTitle,\n DrawerDescription,\n} from './drawer.js'\nexport { default as Link, type LinkProps } from './link.js'\nexport { Avatar, AvatarImage, AvatarFallback } from './avatar.js'\nexport { default as InputNumber, type InputNumberProps } from './input-number.js'\nexport {\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuGroup,\n DropdownMenuPortal,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuRadioGroup,\n} from './drop-down.js'\nexport { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from './card.js'\nexport { default as Countdown, type CountdownProps } from './Countdown.js'\nexport {\n type CarouselApi,\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselPrevious,\n CarouselNext,\n} from './carousel.js'\nexport { Tabs, TabsList, TabsTrigger, TabsContent } from './tabs.js'\nexport { Alert, AlertTitle, AlertDescription } from './alert.js'\nexport { default as Picture } from './picture.js'\nexport { default as Theme } from './theme.js'\nexport { default as Board } from './board.js'\nexport { default as LoadingDots } from './loadingDots.js'\nexport { ExposureDetector, type ExposureDetectorProps } from './ExposureDetector.js'\nexport { default as BrandStrip } from './brand-strip.js'\nexport { default as Progress, type ProgressProps, type ProgressClassNames } from './progress.js'\n"],
|
|
5
|
-
"mappings": "AAAA,OAAoB,WAAXA,MAAyB,cAClC,OAAoB,WAAXA,MAAwB,aACjC,OAAS,SAAAC,EAAO,aAAAC,MAAiB,aAEjC,OAAoB,WAAXF,MAA2B,gBAEpC,OAAoB,WAAXA,MAA2B,gBACpC,OACE,UAAAG,EACA,gBAAAC,EACA,iBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,qBAAAC,MACK,cACP,OAAS,WAAAC,EAAS,kBAAAC,EAAgB,kBAAAC,MAAsB,eACxD,OAAS,cAAAC,EAAY,kBAAAC,MAAsE,aAC3F,OAAS,QAAAC,MAA4B,YACrC,OAAS,QAAAC,EAAM,YAAAC,MAAoD,YACnE,OAAS,WAAAC,MAAkC,eAC3C,OAAS,aAAAC,MAAsC,iBAC/C,OAAS,SAAAC,MAA8B,aACvC,OACE,UAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,iBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,qBAAAC,MACK,cACP,OAAoB,WAAXjC,MAAuC,YAChD,OAAS,UAAAkC,GAAQ,eAAAC,GAAa,kBAAAC,OAAsB,cACpD,OAAoB,WAAXpC,OAAqD,oBAC9D,OACE,gBAAAqC,GACA,uBAAAC,GACA,uBAAAC,GACA,oBAAAC,GACA,4BAAAC,GACA,yBAAAC,GACA,qBAAAC,GACA,yBAAAC,GACA,wBAAAC,GACA,qBAAAC,GACA,sBAAAC,GACA,mBAAAC,GACA,0BAAAC,GACA,0BAAAC,GACA,0BAAAC,OACK,iBACP,OAAS,QAAAC,GAAM,cAAAC,GAAY,cAAAC,GAAY,aAAAC,GAAW,mBAAAC,GAAiB,eAAAC,OAAmB,YACtF,OAAoB,WAAXzD,OAAiD,iBAC1D,OAEE,YAAA0D,GACA,mBAAAC,GACA,gBAAAC,GACA,oBAAAC,GACA,gBAAAC,OACK,gBACP,OAAS,QAAAC,GAAM,YAAAC,GAAU,eAAAC,GAAa,eAAAC,OAAmB,YACzD,OAAS,SAAAC,GAAO,cAAAC,GAAY,oBAAAC,OAAwB,aACpD,OAAoB,WAAXrE,OAA0B,eACnC,OAAoB,WAAXA,OAAwB,aACjC,OAAoB,WAAXA,OAAwB,aACjC,OAAoB,WAAXA,OAA8B,mBACvC,OAAS,oBAAAsE,OAAoD,wBAC7D,OAAoB,WAAXtE,OAA6B,mBACtC,OAAoB,WAAXA,OAAwE",
|
|
4
|
+
"sourcesContent": ["export { default as Button } from './button.js'\nexport { default as Badge } from './badge.js'\nexport { Input, InputSlot } from './input.js'\n\nexport { default as Checkbox } from './checkbox.js'\n\nexport { default as Skeleton } from './skeleton.js'\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogClose,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n} from './dialog.js'\nexport { Popover, PopoverTrigger, PopoverContent } from './popover.js'\nexport { RadioGroup, RadioGroupItem, type RadioGroupProps, type RadioGroupItemProps } from './radio.js'\nexport { Text, type TextProps } from './text.js'\nexport { Grid, GridItem, type GridProps, type GridItemProps } from './grid.js'\nexport { Heading, type HeadingProps } from './heading.js'\nexport { Container, type ContainerProps } from './container.js'\nexport { Color, type ColorProps } from './color.js'\nexport {\n Drawer,\n DrawerPortal,\n DrawerOverlay,\n DrawerTrigger,\n DrawerClose,\n DrawerContent,\n DrawerHeader,\n DrawerFooter,\n DrawerTitle,\n DrawerDescription,\n} from './drawer.js'\nexport { default as Link, type LinkProps } from './link.js'\nexport { Avatar, AvatarImage, AvatarFallback } from './avatar.js'\nexport { default as InputNumber, type InputNumberProps } from './input-number.js'\nexport {\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuGroup,\n DropdownMenuPortal,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuRadioGroup,\n} from './drop-down.js'\nexport { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from './card.js'\nexport { default as Countdown, type CountdownProps } from './Countdown.js'\nexport {\n type CarouselApi,\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselPrevious,\n CarouselNext,\n} from './carousel.js'\nexport { Tabs, TabsList, TabsTrigger, TabsContent } from './tabs.js'\nexport { Alert, AlertTitle, AlertDescription } from './alert.js'\nexport { default as Picture } from './picture.js'\nexport { default as Theme } from './theme.js'\nexport { default as Board } from './board.js'\nexport { default as LoadingDots } from './loadingDots.js'\nexport { ExposureDetector, type ExposureDetectorProps } from './ExposureDetector.js'\nexport { default as BrandStrip } from './brand-strip.js'\nexport { default as Progress, type ProgressProps, type ProgressClassNames } from './progress.js'\nexport { default as OtpInput, type OtpInputProps } from './otp-input.js'\n"],
|
|
5
|
+
"mappings": "AAAA,OAAoB,WAAXA,MAAyB,cAClC,OAAoB,WAAXA,MAAwB,aACjC,OAAS,SAAAC,EAAO,aAAAC,MAAiB,aAEjC,OAAoB,WAAXF,MAA2B,gBAEpC,OAAoB,WAAXA,MAA2B,gBACpC,OACE,UAAAG,EACA,gBAAAC,EACA,iBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,qBAAAC,MACK,cACP,OAAS,WAAAC,EAAS,kBAAAC,EAAgB,kBAAAC,MAAsB,eACxD,OAAS,cAAAC,EAAY,kBAAAC,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DialogOverlay", "DialogClose", "DialogTrigger", "DialogContent", "DialogHeader", "DialogFooter", "DialogTitle", "DialogDescription", "Popover", "PopoverTrigger", "PopoverContent", "RadioGroup", "RadioGroupItem", "Text", "Grid", "GridItem", "Heading", "Container", "Color", "Drawer", "DrawerPortal", "DrawerOverlay", "DrawerTrigger", "DrawerClose", "DrawerContent", "DrawerHeader", "DrawerFooter", "DrawerTitle", "DrawerDescription", "Avatar", "AvatarImage", "AvatarFallback", "DropdownMenu", "DropdownMenuTrigger", "DropdownMenuContent", "DropdownMenuItem", "DropdownMenuCheckboxItem", "DropdownMenuRadioItem", "DropdownMenuLabel", "DropdownMenuSeparator", "DropdownMenuShortcut", "DropdownMenuGroup", "DropdownMenuPortal", "DropdownMenuSub", "DropdownMenuSubContent", "DropdownMenuSubTrigger", "DropdownMenuRadioGroup", "Card", "CardHeader", "CardFooter", "CardTitle", "CardDescription", "CardContent", "Carousel", "CarouselContent", "CarouselItem", "CarouselPrevious", "CarouselNext", "Tabs", "TabsList", "TabsTrigger", "TabsContent", "Alert", "AlertTitle", "AlertDescription", "ExposureDetector"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface OtpInputProps {
|
|
3
|
+
length?: number;
|
|
4
|
+
value?: string;
|
|
5
|
+
onChange?: (value: string) => void;
|
|
6
|
+
onComplete?: (value: string) => void;
|
|
7
|
+
onFocus?: (index: number) => void;
|
|
8
|
+
onBlur?: () => void;
|
|
9
|
+
onPaste?: (text: string) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
cellClassName?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
error?: boolean;
|
|
14
|
+
errorMessage?: string;
|
|
15
|
+
autoFocus?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare const OtpInput: React.ForwardRefExoticComponent<OtpInputProps & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
export default OtpInput;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{jsx as m,jsxs as P}from"react/jsx-runtime";import*as c from"react";import{cn as h}from"../helpers/index.js";const w=c.forwardRef(({length:s=6,value:r="",onChange:u,onComplete:g,onFocus:b,onBlur:E,onPaste:F,className:R,cellClassName:I,disabled:f=!1,error:y=!1,errorMessage:x,autoFocus:D=!1},k)=>{const i=c.useRef([]),[A,p]=c.useState(null),d=c.useRef(!1);c.useEffect(()=>{D&&i.current[0]?.focus()},[D]);const o=e=>{d.current=!0,i.current[e]?.focus()},a=c.useRef(null),v=(e,n)=>{const t=e<r.length;let l;t?l=r.slice(0,e)+n+r.slice(e+1):l=(r+n).slice(0,s),u?.(l),l.length===s?(g?.(l),o(t?Math.min(e+1,s-1):s-1)):o(l.length)},M=(e,n)=>{const t=n.replace(/\D/g,"");t&&v(e,t[0])},N=(e,n)=>{if(/^\d$/.test(e.key))e.preventDefault(),v(n,e.key);else if(e.key==="Backspace"){if(e.preventDefault(),a.current!==null&&a.current<r.length){const t=a.current,l=r.slice(0,t)+r.slice(t+1);u?.(l),o(t>0?t-1:0)}else if(r.length>0){const t=r.slice(0,-1);u?.(t),o(t.length>0?t.length-1:0)}}else if(e.key==="ArrowLeft"){const t=(a.current??0)-1;t>=0&&o(t)}else if(e.key==="ArrowRight"){const t=(a.current??0)+1;t<s&&o(t)}},C=e=>{e.preventDefault();const n=e.clipboardData.getData("text");F?.(n);const t=n.replace(/\D/g,"").slice(0,s);u?.(t),t.length===s&&g?.(t),o(Math.min(t.length,s-1))},O=e=>{if(d.current){d.current=!1,a.current=e,p(e),b?.(e);return}const n=Math.min(r.length,s-1);if(e>n){o(n);return}a.current=e,p(e),b?.(e)},B=()=>{p(null),requestAnimationFrame(()=>{i.current.some(n=>n===document.activeElement)||E?.()})},L=e=>y?"border-[#FF4D4D]":A===e?"border-info-primary":"border-lines-default";return P("div",{ref:k,className:h("otp-input-root flex flex-col gap-2",R),children:[m("div",{className:"laptop:gap-2 flex gap-1.5",children:Array.from({length:s}).map((e,n)=>m("input",{ref:t=>{i.current[n]=t},type:"text",inputMode:"numeric",maxLength:1,value:r[n]??"",disabled:f,readOnly:f,onChange:t=>M(n,t.target.value),onKeyDown:t=>N(t,n),onPaste:C,onFocus:()=>O(n),onBlur:B,className:h("otp-input-cell text-info-primary laptop:size-[54px] rounded-box-small size-[44px] border text-center text-base font-bold transition-colors focus:outline-none",L(n),f&&"text-info-quaternary cursor-not-allowed bg-[#EAEAEC]",I)},n))}),y&&x&&m("span",{className:"otp-input-error text-base font-bold leading-[1.4] tracking-[-0.02em] text-[#FF4D4D]",children:x})]})});w.displayName="OtpInput";var K=w;export{K as default};
|
|
2
|
+
//# sourceMappingURL=otp-input.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/otp-input.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../helpers/index.js'\n\nexport interface OtpInputProps {\n length?: number\n value?: string\n onChange?: (value: string) => void\n onComplete?: (value: string) => void\n onFocus?: (index: number) => void\n onBlur?: () => void\n onPaste?: (text: string) => void\n className?: string\n cellClassName?: string\n disabled?: boolean\n error?: boolean\n errorMessage?: string\n autoFocus?: boolean\n}\n\nconst OtpInput = React.forwardRef<HTMLDivElement, OtpInputProps>(\n (\n {\n length = 6,\n value = '',\n onChange,\n onComplete,\n onFocus,\n onBlur,\n onPaste,\n className,\n cellClassName,\n disabled = false,\n error = false,\n errorMessage,\n autoFocus = false,\n },\n ref\n ) => {\n const inputsRef = React.useRef<Array<HTMLInputElement | null>>([])\n const [focusedIndex, setFocusedIndex] = React.useState<number | null>(null)\n const programmaticFocusRef = React.useRef(false)\n\n React.useEffect(() => {\n if (autoFocus) {\n inputsRef.current[0]?.focus()\n }\n }, [autoFocus])\n\n const focusCell = (index: number) => {\n programmaticFocusRef.current = true\n inputsRef.current[index]?.focus()\n }\n\n const focusedIndexRef = React.useRef<number | null>(null)\n\n const applyDigit = (index: number, digit: string) => {\n const isOverwrite = index < value.length\n let newValue: string\n if (isOverwrite) {\n newValue = value.slice(0, index) + digit + value.slice(index + 1)\n } else {\n newValue = (value + digit).slice(0, length)\n }\n onChange?.(newValue)\n if (newValue.length === length) {\n onComplete?.(newValue)\n focusCell(isOverwrite ? Math.min(index + 1, length - 1) : length - 1)\n } else {\n focusCell(newValue.length)\n }\n }\n\n const handleChange = (index: number, char: string) => {\n const digit = char.replace(/\\D/g, '')\n if (!digit) return\n applyDigit(index, digit[0])\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>, index: number) => {\n if (/^\\d$/.test(e.key)) {\n e.preventDefault()\n applyDigit(index, e.key)\n } else if (e.key === 'Backspace') {\n e.preventDefault()\n if (focusedIndexRef.current !== null && focusedIndexRef.current < value.length) {\n const i = focusedIndexRef.current\n const newValue = value.slice(0, i) + value.slice(i + 1)\n onChange?.(newValue)\n focusCell(i > 0 ? i - 1 : 0)\n } else if (value.length > 0) {\n const newValue = value.slice(0, -1)\n onChange?.(newValue)\n focusCell(newValue.length > 0 ? newValue.length - 1 : 0)\n }\n } else if (e.key === 'ArrowLeft') {\n const prev = (focusedIndexRef.current ?? 0) - 1\n if (prev >= 0) focusCell(prev)\n } else if (e.key === 'ArrowRight') {\n const next = (focusedIndexRef.current ?? 0) + 1\n if (next < length) focusCell(next)\n }\n }\n\n const handlePaste = (e: React.ClipboardEvent) => {\n e.preventDefault()\n const raw = e.clipboardData.getData('text')\n onPaste?.(raw)\n const pasted = raw.replace(/\\D/g, '').slice(0, length)\n onChange?.(pasted)\n if (pasted.length === length) {\n onComplete?.(pasted)\n }\n focusCell(Math.min(pasted.length, length - 1))\n }\n\n const handleFocus = (i: number) => {\n if (programmaticFocusRef.current) {\n programmaticFocusRef.current = false\n focusedIndexRef.current = i\n setFocusedIndex(i)\n onFocus?.(i)\n return\n }\n const firstEmpty = Math.min(value.length, length - 1)\n if (i > firstEmpty) {\n focusCell(firstEmpty)\n return\n }\n focusedIndexRef.current = i\n setFocusedIndex(i)\n onFocus?.(i)\n }\n\n const handleBlur = () => {\n setFocusedIndex(null)\n requestAnimationFrame(() => {\n const anyFocused = inputsRef.current.some(el => el === document.activeElement)\n if (!anyFocused) onBlur?.()\n })\n }\n\n const getCellBorderClass = (index: number) => {\n if (error) return 'border-[#FF4D4D]'\n if (focusedIndex === index) return 'border-info-primary'\n return 'border-lines-default'\n }\n\n return (\n <div ref={ref} className={cn('otp-input-root flex flex-col gap-2', className)}>\n <div className=\"laptop:gap-2 flex gap-1.5\">\n {Array.from({ length }).map((_, i) => (\n <input\n key={i}\n ref={el => {\n inputsRef.current[i] = el\n }}\n type=\"text\"\n inputMode=\"numeric\"\n maxLength={1}\n value={value[i] ?? ''}\n disabled={disabled}\n readOnly={disabled}\n onChange={e => handleChange(i, e.target.value)}\n onKeyDown={e => handleKeyDown(e, i)}\n onPaste={handlePaste}\n onFocus={() => handleFocus(i)}\n onBlur={handleBlur}\n className={cn(\n 'otp-input-cell text-info-primary laptop:size-[54px] rounded-box-small size-[44px] border text-center text-base font-bold transition-colors focus:outline-none',\n getCellBorderClass(i),\n disabled && 'text-info-quaternary cursor-not-allowed bg-[#EAEAEC]',\n cellClassName\n )}\n />\n ))}\n </div>\n {error && errorMessage && (\n <span className=\"otp-input-error text-base font-bold leading-[1.4] tracking-[-0.02em] text-[#FF4D4D]\">\n {errorMessage}\n </span>\n )}\n </div>\n )\n }\n)\n\nOtpInput.displayName = 'OtpInput'\n\nexport default OtpInput\n"],
|
|
5
|
+
"mappings": "aAsJM,OAGM,OAAAA,EAHN,QAAAC,MAAA,oBApJN,UAAYC,MAAW,QACvB,OAAS,MAAAC,MAAU,sBAkBnB,MAAMC,EAAWF,EAAM,WACrB,CACE,CACE,OAAAG,EAAS,EACT,MAAAC,EAAQ,GACR,SAAAC,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,EACA,QAAAC,EACA,UAAAC,EACA,cAAAC,EACA,SAA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IAAI,EACpB,sBAAsB,IAAM,CACPF,EAAU,QAAQ,KAAKuB,GAAMA,IAAO,SAAS,aAAa,GAC5DhC,IAAS,CAC5B,CAAC,CACH,EAEMiC,EAAsBnB,GACtBT,EAAc,mBACdK,IAAiBI,EAAc,sBAC5B,uBAGT,OACEvB,EAAC,OAAI,IAAKiB,EAAK,UAAWf,EAAG,qCAAsCS,CAAS,EAC1E,UAAAZ,EAAC,OAAI,UAAU,4BACZ,eAAM,KAAK,CAAE,OAAAK,CAAO,CAAC,EAAE,IAAI,CAACuC,EAAGX,IAC9BjC,EAAC,SAEC,IAAK0C,GAAM,CACTvB,EAAU,QAAQc,CAAC,EAAIS,CACzB,EACA,KAAK,OACL,UAAU,UACV,UAAW,EACX,MAAOpC,EAAM2B,CAAC,GAAK,GACnB,SAAUnB,EACV,SAAUA,EACV,SAAU+B,GAAKf,EAAaG,EAAGY,EAAE,OAAO,KAAK,EAC7C,UAAWA,GAAKb,EAAca,EAAGZ,CAAC,EAClC,QAASG,EACT,QAAS,IAAMG,EAAYN,CAAC,EAC5B,OAAQQ,EACR,UAAWtC,EACT,gKACAwC,EAAmBV,CAAC,EACpBnB,GAAY,uDACZD,CACF,GApBKoB,CAqBP,CACD,EACH,EACClB,GAASC,GACRhB,EAAC,QAAK,UAAU,sFACb,SAAAgB,EACH,GAEJ,CAEJ,CACF,EAEAZ,EAAS,YAAc,WAEvB,IAAO0C,EAAQ1C",
|
|
6
|
+
"names": ["jsx", "jsxs", "React", "cn", "OtpInput", "length", "value", "onChange", "onComplete", "onFocus", "onBlur", "onPaste", "className", "cellClassName", "disabled", "error", "errorMessage", "autoFocus", "ref", "inputsRef", "focusedIndex", "setFocusedIndex", "programmaticFocusRef", "focusCell", "index", "focusedIndexRef", "applyDigit", "digit", "isOverwrite", "newValue", "handleChange", "char", "handleKeyDown", "i", "prev", "next", "handlePaste", "raw", "pasted", "handleFocus", "firstEmpty", "handleBlur", "el", "getCellBorderClass", "_", "e", "otp_input_default"]
|
|
7
|
+
}
|
|
@@ -57,5 +57,11 @@ export declare const highlightSearchWord: (text: string, searchText: string) =>
|
|
|
57
57
|
* @example
|
|
58
58
|
* // 空路径处理
|
|
59
59
|
* getLocalizedPath('', 'uk') // => ''
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* // appendParams 会自动判断用 ? 还是 &
|
|
63
|
+
* getLocalizedPath('/products', 'us', 'ref=footer') // => '/products?ref=footer'
|
|
64
|
+
* getLocalizedPath('https://example.com/page', 'us', 'ref=footer') // => 'https://example.com/page?ref=footer'
|
|
65
|
+
* getLocalizedPath('https://example.com/page?app=foo', 'us', 'ref=footer') // => 'https://example.com/page?app=foo&ref=footer'
|
|
60
66
|
*/
|
|
61
|
-
export declare const getLocalizedPath: (path: string, locale: string) => string;
|
|
67
|
+
export declare const getLocalizedPath: (path: string, locale: string, appendParams?: string) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{clsx as
|
|
1
|
+
import{clsx as g}from"clsx";import{extendTailwindMerge as c}from"tailwind-merge";const x=c({extend:{theme:{borderRadius:["btn"]},classGroups:{"font-size":["text-heading-1","text-heading-2","text-heading-3","text-heading-4","text-heading-5","text-text-3","text-text-2","text-text-1"],"text-color":["text-info-primary","text-info-secondary","text-info-tertiary","text-info-quaternary","text-info-white"],leading:["leading-tight","leading-normal","leading-loose"]}}});function h(...t){return x(g(t))}function $(){}function a(t){return t&&typeof t=="string"&&t.includes("/")?t.split("/").pop()?.split("?")?.shift():t}const d=t=>t?.replace(/\s+/g,"-"),l=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),y=(t,r)=>{try{if(!t||!r)return t;const e=l(r),n=new RegExp(e,"gi");return t.replace(n,o=>`<span class='text-brand-0 font-bold'>${o}</span>`)}catch(e){return console.error("highlightSearchWord error:",e),t}},b=(t,r,e)=>{if(!t)return t;if(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("#"))return e?t.includes("?")?`${t}&${e}`:`${t}?${e}`:t;const n=t.split("/").filter(Boolean);if(n.length===0){const i=r==="us"?"/":`/${r}`;return e?`${i}?${e}`:i}if(n[0]===r){const i=`/${n.join("/")}`;return e?`${i}?${e}`:i}const s=`${r==="us"?"":`/${r}`}/${n.join("/")}`;return e?`${s}?${e}`:s};export{a as atobID,h as cn,b as getLocalizedPath,y as highlightSearchWord,$ as noop,d as spaceToHyphen};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { clsx, type ClassValue } from 'clsx'\nimport { extendTailwindMerge } from 'tailwind-merge'\n\nconst twMerge = extendTailwindMerge({\n extend: {\n theme: {\n borderRadius: ['btn'],\n },\n classGroups: {\n 'font-size': [\n 'text-heading-1',\n 'text-heading-2',\n 'text-heading-3',\n 'text-heading-4',\n 'text-heading-5',\n 'text-text-3',\n 'text-text-2',\n 'text-text-1',\n ],\n 'text-color': [\n 'text-info-primary',\n 'text-info-secondary',\n 'text-info-tertiary',\n 'text-info-quaternary',\n 'text-info-white',\n ],\n leading: ['leading-tight', 'leading-normal', 'leading-loose'],\n },\n },\n})\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\nexport function noop(): any {}\n\nexport function atobID(id: string) {\n if (id && typeof id === 'string' && id.includes('/')) {\n return id.split('/').pop()?.split('?')?.shift()\n } else {\n return id\n }\n}\nexport const spaceToHyphen = (str: string) => str?.replace(/\\s+/g, '-')\n\n/**\n * \u8F6C\u4E49\u6B63\u5219\u8868\u8FBE\u5F0F\u7279\u6B8A\u5B57\u7B26\n * @param str \u9700\u8981\u8F6C\u4E49\u7684\u5B57\u7B26\u4E32\n * @returns \u8F6C\u4E49\u540E\u7684\u5B57\u7B26\u4E32\n */\nconst escapeRegExp = (str: string): string => {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/**\n * \u9AD8\u4EAE\u641C\u7D22\u5173\u952E\u8BCD\n * @param text \u539F\u59CB\u6587\u672C\n * @param searchText \u641C\u7D22\u5173\u952E\u8BCD\n * @returns \u9AD8\u4EAE\u540E\u7684 HTML \u5B57\u7B26\u4E32\n */\nexport const highlightSearchWord = (text: string, searchText: string) => {\n try {\n if (!text || !searchText) {\n return text\n }\n\n // \u8F6C\u4E49\u641C\u7D22\u6587\u672C\u4E2D\u7684\u6B63\u5219\u8868\u8FBE\u5F0F\u7279\u6B8A\u5B57\u7B26\n const escapedSearchText = escapeRegExp(searchText)\n const regex = new RegExp(escapedSearchText, 'gi')\n\n // \u4F7F\u7528\u6B63\u5219\u8868\u8FBE\u5F0F\u7684\u5339\u914D\u7ED3\u679C\u6765\u4FDD\u6301\u539F\u59CB\u5927\u5C0F\u5199\n return text.replace(regex, match => `<span class='text-brand-0 font-bold'>${match}</span>`)\n } catch (e) {\n console.error('highlightSearchWord error:', e)\n return text\n }\n}\n\n/**\n * \u83B7\u53D6\u672C\u5730\u5316\u8DEF\u5F84\n *\n * \u6839\u636E\u8BED\u8A00\u6807\u8BC6\u4E3A\u8DEF\u5F84\u6DFB\u52A0\u5BF9\u5E94\u7684 locale \u524D\u7F00\u3002\n * - 'us' \u4E3A\u9ED8\u8BA4\u8BED\u8A00\uFF0C\u4E0D\u6DFB\u52A0\u524D\u7F00\n * - \u5176\u4ED6\u8BED\u8A00\u4F1A\u6DFB\u52A0 `/{locale}` \u524D\u7F00\n * - \u5B8C\u6574 URL\uFF08http/https\uFF09\u4E0D\u505A\u5904\u7406\n * - \u81EA\u52A8\u5904\u7406\u8DEF\u5F84\u683C\u5F0F\uFF08\u8865\u5145\u524D\u5BFC\u659C\u6760\u3001\u79FB\u9664\u5C3E\u90E8\u659C\u6760\uFF09\n *\n * @param path - \u539F\u59CB\u8DEF\u5F84\n * @param locale - \u8BED\u8A00\u6807\u8BC6\uFF08\u5982 'us', 'uk', 'de', 'jp' \u7B49\uFF09\n * @returns \u672C\u5730\u5316\u540E\u7684\u8DEF\u5F84\n *\n * @example\n * // \u57FA\u672C\u7528\u6CD5 - \u9ED8\u8BA4\u8BED\u8A00 'us' \u4E0D\u6DFB\u52A0\u524D\u7F00\n * getLocalizedPath('/products', 'us') // => '/products'\n * getLocalizedPath('/about', 'us') // => '/about'\n *\n * @example\n * // \u5176\u4ED6\u8BED\u8A00\u6DFB\u52A0\u524D\u7F00\n * getLocalizedPath('/products', 'uk') // => '/uk/products'\n * getLocalizedPath('/about/team', 'de') // => '/de/about/team'\n * getLocalizedPath('/contact', 'jp') // => '/jp/contact'\n *\n * @example\n * // \u6839\u8DEF\u5F84\u5904\u7406\n * getLocalizedPath('/', 'us') // => '/'\n * getLocalizedPath('/', 'uk') // => '/uk'\n *\n * @example\n * // \u81EA\u52A8\u683C\u5F0F\u5316\u8DEF\u5F84\n * getLocalizedPath('products', 'uk') // => '/uk/products' (\u8865\u5145\u524D\u5BFC\u659C\u6760)\n * getLocalizedPath('/products/', 'uk') // => '/uk/products' (\u79FB\u9664\u5C3E\u90E8\u659C\u6760)\n * getLocalizedPath('//products//detail/', 'uk') // => '/uk/products/detail' (\u79FB\u9664\u591A\u4F59\u659C\u6760)\n *\n * @example\n * // \u5DF2\u5305\u542B locale \u7684\u8DEF\u5F84\u4E0D\u91CD\u590D\u6DFB\u52A0\n * getLocalizedPath('/uk/products', 'uk') // => '/uk/products'\n *\n * @example\n * // \u5B8C\u6574 URL \u4E0D\u5904\u7406\n * getLocalizedPath('https://example.com/page', 'uk') // => 'https://example.com/page'\n * getLocalizedPath('http://example.com', 'de') // => 'http://example.com'\n *\n * @example\n * // \u7A7A\u8DEF\u5F84\u5904\u7406\n * getLocalizedPath('', 'uk') // => ''\n */\nexport const getLocalizedPath = (path: string, locale: string): string => {\n if (!path) return path\n\n // \u5982\u679C\u662F\u5B8C\u6574 URL\uFF08http:// \u6216 https://\uFF09\u6216\u951A\u70B9\u94FE\u63A5\uFF08#\uFF09\uFF0C\u4E0D\u5904\u7406\n if (path.startsWith('http://') || path.startsWith('https://') || path.startsWith('#')) {\n return path\n }\n\n // \u5206\u5272\u8DEF\u5F84\u5E76\u8FC7\u6EE4\u7A7A\u6BB5\uFF08\u5904\u7406\u591A\u4E2A\u8FDE\u7EED\u659C\u6760\u7684\u60C5\u51B5\uFF09\n const pathSegments = path.split('/').filter(Boolean)\n\n // \u5982\u679C\u6CA1\u6709\u6709\u6548\u8DEF\u5F84\u6BB5\uFF0C\u8FD4\u56DE locale \u524D\u7F00\u6216 '/'\n if (pathSegments.length === 0) {\n
|
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,MAA6B,OACtC,OAAS,uBAAAC,MAA2B,iBAEpC,MAAMC,EAAUD,EAAoB,CAClC,OAAQ,CACN,MAAO,CACL,aAAc,CAAC,KAAK,CACtB,EACA,YAAa,CACX,YAAa,CACX,iBACA,iBACA,iBACA,iBACA,iBACA,cACA,cACA,aACF,EACA,aAAc,CACZ,oBACA,sBACA,qBACA,uBACA,iBACF,EACA,QAAS,CAAC,gBAAiB,iBAAkB,eAAe,CAC9D,CACF,CACF,CAAC,EAEM,SAASE,KAAMC,EAAsB,CAC1C,OAAOF,EAAQF,EAAKI,CAAM,CAAC,CAC7B,CAEO,SAASC,GAAY,CAAC,CAEtB,SAASC,EAAOC,EAAY,CACjC,OAAIA,GAAM,OAAOA,GAAO,UAAYA,EAAG,SAAS,GAAG,EAC1CA,EAAG,MAAM,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,GAAG,MAAM,EAEvCA,CAEX,CACO,MAAMC,EAAiBC,GAAgBA,GAAK,QAAQ,OAAQ,GAAG,EAOhEC,EAAgBD,GACbA,EAAI,QAAQ,sBAAuB,MAAM,EASrCE,EAAsB,CAACC,EAAcC,IAAuB,CACvE,GAAI,CACF,GAAI,CAACD,GAAQ,CAACC,EACZ,OAAOD,EAIT,MAAME,EAAoBJ,EAAaG,CAAU,EAC3CE,EAAQ,IAAI,OAAOD,EAAmB,IAAI,EAGhD,OAAOF,EAAK,QAAQG,EAAOC,GAAS,wCAAwCA,CAAK,SAAS,CAC5F,
|
|
6
|
-
"names": ["clsx", "extendTailwindMerge", "twMerge", "cn", "inputs", "noop", "atobID", "id", "spaceToHyphen", "str", "escapeRegExp", "highlightSearchWord", "text", "searchText", "escapedSearchText", "regex", "match", "
|
|
4
|
+
"sourcesContent": ["import { clsx, type ClassValue } from 'clsx'\nimport { extendTailwindMerge } from 'tailwind-merge'\n\nconst twMerge = extendTailwindMerge({\n extend: {\n theme: {\n borderRadius: ['btn'],\n },\n classGroups: {\n 'font-size': [\n 'text-heading-1',\n 'text-heading-2',\n 'text-heading-3',\n 'text-heading-4',\n 'text-heading-5',\n 'text-text-3',\n 'text-text-2',\n 'text-text-1',\n ],\n 'text-color': [\n 'text-info-primary',\n 'text-info-secondary',\n 'text-info-tertiary',\n 'text-info-quaternary',\n 'text-info-white',\n ],\n leading: ['leading-tight', 'leading-normal', 'leading-loose'],\n },\n },\n})\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\nexport function noop(): any {}\n\nexport function atobID(id: string) {\n if (id && typeof id === 'string' && id.includes('/')) {\n return id.split('/').pop()?.split('?')?.shift()\n } else {\n return id\n }\n}\nexport const spaceToHyphen = (str: string) => str?.replace(/\\s+/g, '-')\n\n/**\n * \u8F6C\u4E49\u6B63\u5219\u8868\u8FBE\u5F0F\u7279\u6B8A\u5B57\u7B26\n * @param str \u9700\u8981\u8F6C\u4E49\u7684\u5B57\u7B26\u4E32\n * @returns \u8F6C\u4E49\u540E\u7684\u5B57\u7B26\u4E32\n */\nconst escapeRegExp = (str: string): string => {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/**\n * \u9AD8\u4EAE\u641C\u7D22\u5173\u952E\u8BCD\n * @param text \u539F\u59CB\u6587\u672C\n * @param searchText \u641C\u7D22\u5173\u952E\u8BCD\n * @returns \u9AD8\u4EAE\u540E\u7684 HTML \u5B57\u7B26\u4E32\n */\nexport const highlightSearchWord = (text: string, searchText: string) => {\n try {\n if (!text || !searchText) {\n return text\n }\n\n // \u8F6C\u4E49\u641C\u7D22\u6587\u672C\u4E2D\u7684\u6B63\u5219\u8868\u8FBE\u5F0F\u7279\u6B8A\u5B57\u7B26\n const escapedSearchText = escapeRegExp(searchText)\n const regex = new RegExp(escapedSearchText, 'gi')\n\n // \u4F7F\u7528\u6B63\u5219\u8868\u8FBE\u5F0F\u7684\u5339\u914D\u7ED3\u679C\u6765\u4FDD\u6301\u539F\u59CB\u5927\u5C0F\u5199\n return text.replace(regex, match => `<span class='text-brand-0 font-bold'>${match}</span>`)\n } catch (e) {\n console.error('highlightSearchWord error:', e)\n return text\n }\n}\n\n/**\n * \u83B7\u53D6\u672C\u5730\u5316\u8DEF\u5F84\n *\n * \u6839\u636E\u8BED\u8A00\u6807\u8BC6\u4E3A\u8DEF\u5F84\u6DFB\u52A0\u5BF9\u5E94\u7684 locale \u524D\u7F00\u3002\n * - 'us' \u4E3A\u9ED8\u8BA4\u8BED\u8A00\uFF0C\u4E0D\u6DFB\u52A0\u524D\u7F00\n * - \u5176\u4ED6\u8BED\u8A00\u4F1A\u6DFB\u52A0 `/{locale}` \u524D\u7F00\n * - \u5B8C\u6574 URL\uFF08http/https\uFF09\u4E0D\u505A\u5904\u7406\n * - \u81EA\u52A8\u5904\u7406\u8DEF\u5F84\u683C\u5F0F\uFF08\u8865\u5145\u524D\u5BFC\u659C\u6760\u3001\u79FB\u9664\u5C3E\u90E8\u659C\u6760\uFF09\n *\n * @param path - \u539F\u59CB\u8DEF\u5F84\n * @param locale - \u8BED\u8A00\u6807\u8BC6\uFF08\u5982 'us', 'uk', 'de', 'jp' \u7B49\uFF09\n * @returns \u672C\u5730\u5316\u540E\u7684\u8DEF\u5F84\n *\n * @example\n * // \u57FA\u672C\u7528\u6CD5 - \u9ED8\u8BA4\u8BED\u8A00 'us' \u4E0D\u6DFB\u52A0\u524D\u7F00\n * getLocalizedPath('/products', 'us') // => '/products'\n * getLocalizedPath('/about', 'us') // => '/about'\n *\n * @example\n * // \u5176\u4ED6\u8BED\u8A00\u6DFB\u52A0\u524D\u7F00\n * getLocalizedPath('/products', 'uk') // => '/uk/products'\n * getLocalizedPath('/about/team', 'de') // => '/de/about/team'\n * getLocalizedPath('/contact', 'jp') // => '/jp/contact'\n *\n * @example\n * // \u6839\u8DEF\u5F84\u5904\u7406\n * getLocalizedPath('/', 'us') // => '/'\n * getLocalizedPath('/', 'uk') // => '/uk'\n *\n * @example\n * // \u81EA\u52A8\u683C\u5F0F\u5316\u8DEF\u5F84\n * getLocalizedPath('products', 'uk') // => '/uk/products' (\u8865\u5145\u524D\u5BFC\u659C\u6760)\n * getLocalizedPath('/products/', 'uk') // => '/uk/products' (\u79FB\u9664\u5C3E\u90E8\u659C\u6760)\n * getLocalizedPath('//products//detail/', 'uk') // => '/uk/products/detail' (\u79FB\u9664\u591A\u4F59\u659C\u6760)\n *\n * @example\n * // \u5DF2\u5305\u542B locale \u7684\u8DEF\u5F84\u4E0D\u91CD\u590D\u6DFB\u52A0\n * getLocalizedPath('/uk/products', 'uk') // => '/uk/products'\n *\n * @example\n * // \u5B8C\u6574 URL \u4E0D\u5904\u7406\n * getLocalizedPath('https://example.com/page', 'uk') // => 'https://example.com/page'\n * getLocalizedPath('http://example.com', 'de') // => 'http://example.com'\n *\n * @example\n * // \u7A7A\u8DEF\u5F84\u5904\u7406\n * getLocalizedPath('', 'uk') // => ''\n *\n * @example\n * // appendParams \u4F1A\u81EA\u52A8\u5224\u65AD\u7528 ? \u8FD8\u662F &\n * getLocalizedPath('/products', 'us', 'ref=footer') // => '/products?ref=footer'\n * getLocalizedPath('https://example.com/page', 'us', 'ref=footer') // => 'https://example.com/page?ref=footer'\n * getLocalizedPath('https://example.com/page?app=foo', 'us', 'ref=footer') // => 'https://example.com/page?app=foo&ref=footer'\n */\nexport const getLocalizedPath = (path: string, locale: string, appendParams?: string): string => {\n if (!path) return path\n\n // \u5982\u679C\u662F\u5B8C\u6574 URL\uFF08http:// \u6216 https://\uFF09\u6216\u951A\u70B9\u94FE\u63A5\uFF08#\uFF09\uFF0C\u4E0D\u5904\u7406 locale\uFF0C\u4F46\u9700\u5904\u7406 appendParams\n if (path.startsWith('http://') || path.startsWith('https://') || path.startsWith('#')) {\n if (!appendParams) return path\n return path.includes('?') ? `${path}&${appendParams}` : `${path}?${appendParams}`\n }\n\n // \u5206\u5272\u8DEF\u5F84\u5E76\u8FC7\u6EE4\u7A7A\u6BB5\uFF08\u5904\u7406\u591A\u4E2A\u8FDE\u7EED\u659C\u6760\u7684\u60C5\u51B5\uFF09\n const pathSegments = path.split('/').filter(Boolean)\n\n // \u5982\u679C\u6CA1\u6709\u6709\u6548\u8DEF\u5F84\u6BB5\uFF0C\u8FD4\u56DE locale \u524D\u7F00\u6216 '/'\n if (pathSegments.length === 0) {\n const base = locale === 'us' ? '/' : `/${locale}`\n return appendParams ? `${base}?${appendParams}` : base\n }\n\n // \u68C0\u67E5\u8DEF\u5F84\u662F\u5426\u5DF2\u7ECF\u5305\u542B locale\n if (pathSegments[0] === locale) {\n const base = `/${pathSegments.join('/')}`\n return appendParams ? `${base}?${appendParams}` : base\n }\n\n // \u83B7\u53D6 locale \u524D\u7F00\u5E76\u62FC\u63A5\n const localePrefix = locale === 'us' ? '' : `/${locale}`\n const base = `${localePrefix}/${pathSegments.join('/')}`\n return appendParams ? `${base}?${appendParams}` : base\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,MAA6B,OACtC,OAAS,uBAAAC,MAA2B,iBAEpC,MAAMC,EAAUD,EAAoB,CAClC,OAAQ,CACN,MAAO,CACL,aAAc,CAAC,KAAK,CACtB,EACA,YAAa,CACX,YAAa,CACX,iBACA,iBACA,iBACA,iBACA,iBACA,cACA,cACA,aACF,EACA,aAAc,CACZ,oBACA,sBACA,qBACA,uBACA,iBACF,EACA,QAAS,CAAC,gBAAiB,iBAAkB,eAAe,CAC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a,KAAK,GAAG,CAAC,GACvC,OAAOD,EAAe,GAAGE,CAAI,IAAIF,CAAY,GAAKE,CACpD,CAIA,MAAMA,EAAO,GADQH,IAAW,KAAO,GAAK,IAAIA,CAAM,EAC1B,IAAIE,EAAa,KAAK,GAAG,CAAC,GACtD,OAAOD,EAAe,GAAGE,CAAI,IAAIF,CAAY,GAAKE,CACpD",
|
|
6
|
+
"names": ["clsx", "extendTailwindMerge", "twMerge", "cn", "inputs", "noop", "atobID", "id", "spaceToHyphen", "str", "escapeRegExp", "highlightSearchWord", "text", "searchText", "escapedSearchText", "regex", "match", "getLocalizedPath", "path", "locale", "appendParams", "pathSegments", "base"]
|
|
7
7
|
}
|