asterui 0.12.62 → 0.12.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Anchor.d.ts +2 -0
- package/dist/components/Anchor.js +79 -75
- package/dist/components/Anchor.js.map +1 -1
- package/dist/components/Autocomplete.d.ts +1 -0
- package/dist/components/Autocomplete.js +115 -110
- package/dist/components/Autocomplete.js.map +1 -1
- package/dist/components/Breadcrumb.d.ts +4 -2
- package/dist/components/Breadcrumb.js +54 -29
- package/dist/components/Breadcrumb.js.map +1 -1
- package/dist/components/Button.d.ts +5 -1
- package/dist/components/Button.js +117 -107
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Chart.d.ts +1 -0
- package/dist/components/Chart.js +31 -30
- package/dist/components/Chart.js.map +1 -1
- package/dist/components/Chat.d.ts +1 -0
- package/dist/components/Chat.js +32 -30
- package/dist/components/Chat.js.map +1 -1
- package/dist/components/Command.d.ts +5 -2
- package/dist/components/Command.js +262 -233
- package/dist/components/Command.js.map +1 -1
- package/dist/components/ContextMenu.d.ts +4 -0
- package/dist/components/ContextMenu.js +149 -130
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/Dock.d.ts +2 -0
- package/dist/components/Dock.js +70 -46
- package/dist/components/Dock.js.map +1 -1
- package/dist/components/FileInput.d.ts +1 -0
- package/dist/components/FileInput.js +26 -26
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Filter.d.ts +1 -0
- package/dist/components/Filter.js +43 -40
- package/dist/components/Filter.js.map +1 -1
- package/dist/components/Flex.d.ts +1 -0
- package/dist/components/Flex.js +43 -42
- package/dist/components/Flex.js.map +1 -1
- package/dist/components/FloatButton.d.ts +3 -0
- package/dist/components/FloatButton.js +178 -127
- package/dist/components/FloatButton.js.map +1 -1
- package/dist/components/Input.d.ts +1 -0
- package/dist/components/Input.js +201 -184
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Loading.d.ts +1 -0
- package/dist/components/Loading.js +40 -37
- package/dist/components/Loading.js.map +1 -1
- package/dist/components/Masonry.d.ts +1 -0
- package/dist/components/Masonry.js +45 -42
- package/dist/components/Masonry.js.map +1 -1
- package/dist/components/Mention.d.ts +1 -0
- package/dist/components/Mention.js +95 -91
- package/dist/components/Mention.js.map +1 -1
- package/dist/components/MonthCalendar.d.ts +1 -0
- package/dist/components/MonthCalendar.js +104 -97
- package/dist/components/MonthCalendar.js.map +1 -1
- package/dist/components/QRCode.d.ts +1 -0
- package/dist/components/QRCode.js +84 -55
- package/dist/components/QRCode.js.map +1 -1
- package/dist/components/RadialProgress.d.ts +1 -0
- package/dist/components/RadialProgress.js +19 -17
- package/dist/components/RadialProgress.js.map +1 -1
- package/dist/components/Range.d.ts +1 -0
- package/dist/components/Range.js +45 -43
- package/dist/components/Range.js.map +1 -1
- package/dist/components/Rating.d.ts +4 -2
- package/dist/components/Rating.js +83 -79
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/Responsive.d.ts +4 -2
- package/dist/components/Responsive.js +10 -9
- package/dist/components/Responsive.js.map +1 -1
- package/dist/components/Result.d.ts +1 -0
- package/dist/components/Result.js +24 -22
- package/dist/components/Result.js.map +1 -1
- package/dist/components/Select.d.ts +1 -0
- package/dist/components/Select.js +72 -62
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Splitter.d.ts +2 -0
- package/dist/components/Splitter.js +137 -131
- package/dist/components/Splitter.js.map +1 -1
- package/dist/components/Stat.d.ts +4 -2
- package/dist/components/Stat.js +19 -18
- package/dist/components/Stat.js.map +1 -1
- package/dist/components/Steps.d.ts +4 -2
- package/dist/components/Steps.js +56 -52
- package/dist/components/Steps.js.map +1 -1
- package/dist/components/TextRotate.d.ts +1 -0
- package/dist/components/TextRotate.js +14 -12
- package/dist/components/TextRotate.js.map +1 -1
- package/dist/components/Textarea.d.ts +1 -0
- package/dist/components/Textarea.js +31 -30
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/ThemeController.d.ts +6 -3
- package/dist/components/ThemeController.js +101 -92
- package/dist/components/ThemeController.js.map +1 -1
- package/dist/components/Typography.d.ts +10 -5
- package/dist/components/Typography.js +84 -81
- package/dist/components/Typography.js.map +1 -1
- package/dist/components/VirtualList.d.ts +2 -1
- package/dist/components/VirtualList.js +40 -36
- package/dist/components/VirtualList.js.map +1 -1
- package/dist/components/Watermark.d.ts +1 -0
- package/dist/components/Watermark.js +74 -71
- package/dist/components/Watermark.js.map +1 -1
- package/dist/components/WeekCalendar.d.ts +1 -0
- package/dist/components/WeekCalendar.js +91 -76
- package/dist/components/WeekCalendar.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatButton.js","sources":["../../src/components/FloatButton.tsx"],"sourcesContent":["import React, { useState, useEffect, createContext, useContext } from 'react'\n\n// DaisyUI classes\nconst dBtn = 'btn'\nconst dBtnLg = 'btn-lg'\nconst dBtnCircle = 'btn-circle'\nconst dBtnSquare = 'btn-square'\nconst dBtnNeutral = 'btn-neutral'\nconst dBtnPrimary = 'btn-primary'\nconst dTooltip = 'tooltip'\nconst dTooltipLeft = 'tooltip-left'\nconst dTooltipRight = 'tooltip-right'\nconst dTooltipTop = 'tooltip-top'\nconst dTooltipBottom = 'tooltip-bottom'\nconst dIndicator = 'indicator'\nconst dIndicatorItem = 'indicator-item'\nconst dBadge = 'badge'\nconst dBadgeSecondary = 'badge-secondary'\nconst dFab = 'fab'\nconst dFabFlower = 'fab-flower'\nconst dFabMainAction = 'fab-main-action'\nconst dFabClose = 'fab-close'\n\n// Default icons\nconst PlusIcon = () => (\n <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-6 w-6\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M12 4v16m8-8H4\" />\n </svg>\n)\n\nconst ArrowUpIcon = () => (\n <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-6 w-6\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M5 10l7-7m0 0l7 7m-7-7v18\" />\n </svg>\n)\n\nconst CloseIcon = () => (\n <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-6 w-6\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n)\n\nexport interface FloatButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n /** Icon to display */\n icon?: React.ReactNode\n /** Description text below icon */\n description?: React.ReactNode\n /** Button type/color */\n type?: 'default' | 'primary'\n /** Button shape */\n shape?: 'circle' | 'square'\n /** Tooltip text */\n tooltip?: string\n /** Tooltip placement */\n tooltipPlacement?: 'left' | 'right' | 'top' | 'bottom'\n /** Badge content */\n badge?: number | React.ReactNode\n /** Link URL (renders as anchor) */\n href?: string\n /** Link target */\n target?: string\n /** @deprecated Use icon prop instead */\n children?: React.ReactNode\n}\n\nexport interface FloatButtonGroupProps {\n /** Child FloatButton components */\n children: React.ReactNode\n /** Arrange buttons in a quarter-circle (radial) layout */\n flower?: boolean\n /** Button shape for children */\n shape?: 'circle' | 'square'\n /** Main trigger button icon */\n icon?: React.ReactNode\n /** Accessible label for trigger button (required for icon-only buttons) */\n triggerLabel?: string\n /** Main action button that replaces trigger when open (fab-main-action) */\n mainAction?: React.ReactNode\n /** Accessible label for main action button */\n mainActionLabel?: string\n /** Click handler for main action button */\n onMainAction?: () => void\n /** Show close button when open (fab-close) */\n showClose?: boolean\n /** Accessible label for close button */\n closeLabel?: string\n /** Button type/color */\n type?: 'default' | 'primary'\n /** Position on screen */\n position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'\n /** Distance from edge */\n offset?: number\n /** Additional CSS classes */\n className?: string\n /** Custom styles */\n style?: React.CSSProperties\n}\n\nexport interface BackTopProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'onClick'> {\n /** Scroll threshold to show button (pixels) */\n visibilityHeight?: number\n /** Scroll target (default: window) */\n target?: () => HTMLElement | Window\n /** Click handler (called before scrolling) */\n onClick?: () => void\n /** Custom icon */\n icon?: React.ReactNode\n /** Duration of scroll animation in ms */\n duration?: number\n /** Position on screen */\n position?: 'bottom-right' | 'bottom-left'\n /** Distance from edge in pixels */\n offset?: number\n /** @deprecated Use icon prop instead */\n children?: React.ReactNode\n}\n\n// Context for group\ninterface FloatButtonGroupContextValue {\n inGroup: boolean\n shape?: 'circle' | 'square'\n}\n\nconst FloatButtonGroupContext = createContext<FloatButtonGroupContextValue>({ inGroup: false })\n\nconst tooltipPlacementClasses: Record<string, string> = {\n left: dTooltipLeft,\n right: dTooltipRight,\n top: dTooltipTop,\n bottom: dTooltipBottom,\n}\n\nconst typeClasses: Record<string, string> = {\n default: dBtnNeutral,\n primary: dBtnPrimary,\n}\n\nconst shapeClasses: Record<string, string> = {\n circle: dBtnCircle,\n square: dBtnSquare,\n}\n\ninterface FloatButtonComponent extends React.FC<FloatButtonProps> {\n Group: React.FC<FloatButtonGroupProps>\n BackTop: React.FC<BackTopProps>\n}\n\nconst FloatButtonBase: React.FC<FloatButtonProps & { style?: React.CSSProperties }> = ({\n icon,\n description,\n onClick,\n type = 'default',\n shape = 'circle',\n className = '',\n tooltip,\n tooltipPlacement = 'left',\n badge,\n href,\n target,\n children,\n style,\n ...rest\n}) => {\n const groupContext = useContext(FloatButtonGroupContext)\n const effectiveShape = groupContext.inGroup ? (groupContext.shape || shape) : shape\n\n const buttonClasses = [\n dBtn,\n dBtnLg,\n 'shadow-lg',\n shapeClasses[effectiveShape],\n typeClasses[type],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const content = icon || children || <PlusIcon />\n\n const buttonContent = (\n <>\n {description ? (\n <div className=\"flex flex-col items-center\">\n {content}\n <span className=\"text-xs mt-1\">{description}</span>\n </div>\n ) : (\n content\n )}\n </>\n )\n\n // When inside a group, render simple button without wrapper divs\n // DaisyUI's fab CSS requires direct button children\n if (groupContext.inGroup) {\n return href ? (\n <a\n href={href}\n target={target}\n className={buttonClasses}\n title={tooltip}\n onClick={onClick as any}\n {...(rest as any)}\n >\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} title={tooltip} onClick={onClick} {...rest}>\n {buttonContent}\n </button>\n )\n }\n\n const buttonElement = href ? (\n <a\n href={href}\n target={target}\n className={buttonClasses}\n style={style}\n onClick={onClick as any}\n {...(rest as any)}\n >\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} onClick={onClick} style={style} {...rest}>\n {buttonContent}\n </button>\n )\n\n const withBadge = badge !== undefined ? (\n <div className={dIndicator} style={style}>\n <span className={`${dIndicatorItem} ${dBadge} ${dBadgeSecondary}`}>\n {badge}\n </span>\n {href ? (\n <a href={href} target={target} className={buttonClasses} onClick={onClick as any} {...(rest as any)}>\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} onClick={onClick} {...rest}>\n {buttonContent}\n </button>\n )}\n </div>\n ) : buttonElement\n\n if (tooltip) {\n return (\n <div className={`${dTooltip} ${tooltipPlacementClasses[tooltipPlacement]}`} data-tip={tooltip} style={style}>\n {badge !== undefined ? (\n <div className={dIndicator}>\n <span className={`${dIndicatorItem} ${dBadge} ${dBadgeSecondary}`}>{badge}</span>\n {href ? (\n <a href={href} target={target} className={buttonClasses} onClick={onClick as any} {...(rest as any)}>\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} onClick={onClick} {...rest}>\n {buttonContent}\n </button>\n )}\n </div>\n ) : href ? (\n <a href={href} target={target} className={buttonClasses} onClick={onClick as any} {...(rest as any)}>\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} onClick={onClick} {...rest}>\n {buttonContent}\n </button>\n )}\n </div>\n )\n }\n\n return withBadge\n}\n\nexport const FloatButton: FloatButtonComponent = (props) => {\n const {\n style: propStyle,\n ...rest\n } = props\n\n const groupContext = useContext(FloatButtonGroupContext)\n\n // If in group, don't apply fixed positioning\n if (groupContext.inGroup) {\n return <FloatButtonBase {...rest} />\n }\n\n // Standalone button with fixed positioning\n const style: React.CSSProperties = {\n position: 'fixed',\n zIndex: 1000,\n bottom: 24,\n right: 24,\n ...propStyle,\n }\n\n return <FloatButtonBase {...rest} style={style} />\n}\n\nconst FloatButtonGroup: React.FC<FloatButtonGroupProps> = ({\n children,\n flower = false,\n shape = 'circle',\n icon,\n triggerLabel = 'Open menu',\n mainAction,\n mainActionLabel,\n onMainAction,\n showClose = false,\n closeLabel = 'Close menu',\n type = 'default',\n position = 'bottom-right',\n offset = 24,\n className = '',\n style: propStyle,\n}) => {\n const fabClasses = [\n dFab,\n flower ? dFabFlower : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const triggerButtonClasses = [\n dBtn,\n dBtnLg,\n 'shadow-lg',\n shapeClasses[shape],\n typeClasses[type],\n ]\n .filter(Boolean)\n .join(' ')\n\n const containerStyle: React.CSSProperties = {\n ...(position.includes('bottom') ? { bottom: offset } : { top: offset }),\n ...(position.includes('right') ? { right: offset } : { left: offset }),\n ...propStyle,\n }\n\n return (\n <div className={fabClasses} style={containerStyle}>\n {/* Trigger button - shown when closed */}\n <button\n type=\"button\"\n className={triggerButtonClasses}\n aria-label={triggerLabel}\n aria-haspopup=\"true\"\n >\n {icon || <PlusIcon />}\n </button>\n\n {/* Main action button - shown when open (replaces trigger in flower mode) */}\n {mainAction && (\n <button\n type=\"button\"\n className={`${triggerButtonClasses} ${dFabMainAction}`}\n onClick={onMainAction}\n aria-label={mainActionLabel}\n >\n {mainAction}\n </button>\n )}\n\n {/* Close button - shown when open */}\n {showClose && (\n <button\n type=\"button\"\n className={`${triggerButtonClasses} ${dFabClose}`}\n aria-label={closeLabel}\n >\n <CloseIcon />\n </button>\n )}\n\n <FloatButtonGroupContext.Provider value={{ inGroup: true, shape }}>\n {children}\n </FloatButtonGroupContext.Provider>\n </div>\n )\n}\n\nconst BackTop: React.FC<BackTopProps> = ({\n visibilityHeight = 400,\n target,\n onClick,\n icon,\n duration = 450,\n position = 'bottom-right',\n offset = 24,\n className = '',\n children,\n style: propStyle,\n ...rest\n}) => {\n const [visible, setVisible] = useState(false)\n\n useEffect(() => {\n const scrollTarget = target ? target() : window\n\n const handleScroll = () => {\n const scrollTop =\n scrollTarget instanceof Window\n ? window.scrollY\n : (scrollTarget as HTMLElement).scrollTop\n\n setVisible(scrollTop >= visibilityHeight)\n }\n\n scrollTarget.addEventListener('scroll', handleScroll)\n handleScroll()\n\n return () => scrollTarget.removeEventListener('scroll', handleScroll)\n }, [target, visibilityHeight])\n\n const handleClick = () => {\n onClick?.()\n const scrollTarget = target ? target() : window\n if (scrollTarget instanceof Window) {\n window.scrollTo({ top: 0, behavior: 'smooth' })\n } else {\n (scrollTarget as HTMLElement).scrollTo({ top: 0, behavior: 'smooth' })\n }\n }\n\n if (!visible) return null\n\n const buttonClasses = [\n dBtn,\n dBtnLg,\n dBtnCircle,\n dBtnNeutral,\n 'shadow-lg',\n 'transition-opacity',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const style: React.CSSProperties = {\n position: 'fixed',\n zIndex: 1000,\n bottom: offset,\n ...(position.includes('right') ? { right: offset } : { left: offset }),\n ...propStyle,\n }\n\n return (\n <button\n className={buttonClasses}\n onClick={handleClick}\n style={style}\n aria-label={rest['aria-label'] || 'Back to top'}\n {...rest}\n >\n {icon || children || <ArrowUpIcon />}\n </button>\n )\n}\n\nFloatButton.Group = FloatButtonGroup\nFloatButton.BackTop = BackTop\n"],"names":["dBtn","dBtnLg","dBtnCircle","dBtnSquare","dBtnNeutral","dBtnPrimary","dTooltip","dTooltipLeft","dTooltipRight","dTooltipTop","dTooltipBottom","dIndicator","dIndicatorItem","dBadge","dBadgeSecondary","dFab","dFabFlower","dFabMainAction","dFabClose","PlusIcon","jsx","ArrowUpIcon","CloseIcon","FloatButtonGroupContext","createContext","tooltipPlacementClasses","typeClasses","shapeClasses","FloatButtonBase","icon","description","onClick","type","shape","className","tooltip","tooltipPlacement","badge","href","target","children","style","rest","groupContext","useContext","effectiveShape","buttonClasses","content","buttonContent","Fragment","jsxs","buttonElement","withBadge","FloatButton","props","propStyle","FloatButtonGroup","flower","triggerLabel","mainAction","mainActionLabel","onMainAction","showClose","closeLabel","position","offset","fabClasses","triggerButtonClasses","containerStyle","BackTop","visibilityHeight","duration","visible","setVisible","useState","useEffect","scrollTarget","handleScroll","scrollTop","handleClick"],"mappings":";;AAGA,MAAMA,IAAO,OACPC,IAAS,UACTC,IAAa,cACbC,IAAa,cACbC,IAAc,eACdC,IAAc,eACdC,IAAW,WACXC,IAAe,gBACfC,IAAgB,iBAChBC,IAAc,eACdC,IAAiB,kBACjBC,IAAa,aACbC,IAAiB,kBACjBC,IAAS,SACTC,IAAkB,mBAClBC,IAAO,OACPC,IAAa,cACbC,IAAiB,mBACjBC,IAAY,aAGZC,IAAW,MACf,gBAAAC,EAAC,OAAA,EAAI,OAAM,8BAA6B,WAAU,WAAU,MAAK,QAAO,SAAQ,aAAY,QAAO,gBACjG,UAAA,gBAAAA,EAAC,QAAA,EAAK,eAAc,SAAQ,gBAAe,SAAQ,aAAa,GAAG,GAAE,iBAAA,CAAiB,EAAA,CACxF,GAGIC,IAAc,MAClB,gBAAAD,EAAC,OAAA,EAAI,OAAM,8BAA6B,WAAU,WAAU,MAAK,QAAO,SAAQ,aAAY,QAAO,gBACjG,UAAA,gBAAAA,EAAC,QAAA,EAAK,eAAc,SAAQ,gBAAe,SAAQ,aAAa,GAAG,GAAE,4BAAA,CAA4B,EAAA,CACnG,GAGIE,KAAY,MAChB,gBAAAF,EAAC,OAAA,EAAI,OAAM,8BAA6B,WAAU,WAAU,MAAK,QAAO,SAAQ,aAAY,QAAO,gBACjG,UAAA,gBAAAA,EAAC,QAAA,EAAK,eAAc,SAAQ,gBAAe,SAAQ,aAAa,GAAG,GAAE,uBAAA,CAAuB,E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AAS,SAAS,OAAO,IAAI,EAAE,OAAOC,EAAA,IAAW,EAAE,MAAMA,EAAA;AAAA,IAC7D,GAAGV;AAAA,EAAA;AAGL,SACE,gBAAAnC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW0B;AAAA,MACX,SAASiC;AAAA,MACT,OAAAtC;AAAA,MACA,cAAYC,EAAK,YAAY,KAAK;AAAA,MACjC,GAAGA;AAAA,MAEH,UAAAb,KAAQW,KAAY,gBAAApB,EAACC,GAAA,CAAA,CAAY;AAAA,IAAA;AAAA,EAAA;AAGxC;AAEAgC,EAAY,QAAQG;AACpBH,EAAY,UAAUgB;"}
|
|
1
|
+
{"version":3,"file":"FloatButton.js","sources":["../../src/components/FloatButton.tsx"],"sourcesContent":["import React, { useState, useEffect, createContext, useContext } from 'react'\n\n// DaisyUI classes\nconst dBtn = 'btn'\nconst dBtnLg = 'btn-lg'\nconst dBtnCircle = 'btn-circle'\nconst dBtnSquare = 'btn-square'\nconst dBtnNeutral = 'btn-neutral'\nconst dBtnPrimary = 'btn-primary'\nconst dTooltip = 'tooltip'\nconst dTooltipLeft = 'tooltip-left'\nconst dTooltipRight = 'tooltip-right'\nconst dTooltipTop = 'tooltip-top'\nconst dTooltipBottom = 'tooltip-bottom'\nconst dIndicator = 'indicator'\nconst dIndicatorItem = 'indicator-item'\nconst dBadge = 'badge'\nconst dBadgeSecondary = 'badge-secondary'\nconst dFab = 'fab'\nconst dFabFlower = 'fab-flower'\nconst dFabMainAction = 'fab-main-action'\nconst dFabClose = 'fab-close'\n\n// Default icons\nconst PlusIcon = () => (\n <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-6 w-6\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M12 4v16m8-8H4\" />\n </svg>\n)\n\nconst ArrowUpIcon = () => (\n <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-6 w-6\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M5 10l7-7m0 0l7 7m-7-7v18\" />\n </svg>\n)\n\nconst CloseIcon = () => (\n <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-6 w-6\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n)\n\nexport interface FloatButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n /** Icon to display */\n icon?: React.ReactNode\n /** Description text below icon */\n description?: React.ReactNode\n /** Button type/color */\n type?: 'default' | 'primary'\n /** Button shape */\n shape?: 'circle' | 'square'\n /** Tooltip text */\n tooltip?: string\n /** Tooltip placement */\n tooltipPlacement?: 'left' | 'right' | 'top' | 'bottom'\n /** Badge content */\n badge?: number | React.ReactNode\n /** Link URL (renders as anchor) */\n href?: string\n /** Link target */\n target?: string\n /** @deprecated Use icon prop instead */\n children?: React.ReactNode\n 'data-testid'?: string\n}\n\nexport interface FloatButtonGroupProps {\n /** Child FloatButton components */\n children: React.ReactNode\n /** Arrange buttons in a quarter-circle (radial) layout */\n flower?: boolean\n /** Button shape for children */\n shape?: 'circle' | 'square'\n /** Main trigger button icon */\n icon?: React.ReactNode\n /** Accessible label for trigger button (required for icon-only buttons) */\n triggerLabel?: string\n /** Main action button that replaces trigger when open (fab-main-action) */\n mainAction?: React.ReactNode\n /** Accessible label for main action button */\n mainActionLabel?: string\n /** Click handler for main action button */\n onMainAction?: () => void\n /** Show close button when open (fab-close) */\n showClose?: boolean\n /** Accessible label for close button */\n closeLabel?: string\n /** Button type/color */\n type?: 'default' | 'primary'\n /** Position on screen */\n position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'\n /** Distance from edge */\n offset?: number\n /** Additional CSS classes */\n className?: string\n /** Custom styles */\n style?: React.CSSProperties\n 'data-testid'?: string\n}\n\nexport interface BackTopProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'onClick'> {\n /** Scroll threshold to show button (pixels) */\n visibilityHeight?: number\n /** Scroll target (default: window) */\n target?: () => HTMLElement | Window\n /** Click handler (called before scrolling) */\n onClick?: () => void\n /** Custom icon */\n icon?: React.ReactNode\n /** Duration of scroll animation in ms */\n duration?: number\n /** Position on screen */\n position?: 'bottom-right' | 'bottom-left'\n /** Distance from edge in pixels */\n offset?: number\n /** @deprecated Use icon prop instead */\n children?: React.ReactNode\n 'data-testid'?: string\n}\n\n// Context for group\ninterface FloatButtonGroupContextValue {\n inGroup: boolean\n shape?: 'circle' | 'square'\n}\n\nconst FloatButtonGroupContext = createContext<FloatButtonGroupContextValue>({ inGroup: false })\n\nconst tooltipPlacementClasses: Record<string, string> = {\n left: dTooltipLeft,\n right: dTooltipRight,\n top: dTooltipTop,\n bottom: dTooltipBottom,\n}\n\nconst typeClasses: Record<string, string> = {\n default: dBtnNeutral,\n primary: dBtnPrimary,\n}\n\nconst shapeClasses: Record<string, string> = {\n circle: dBtnCircle,\n square: dBtnSquare,\n}\n\ninterface FloatButtonComponent extends React.FC<FloatButtonProps> {\n Group: React.FC<FloatButtonGroupProps>\n BackTop: React.FC<BackTopProps>\n}\n\nconst FloatButtonBase: React.FC<FloatButtonProps & { style?: React.CSSProperties }> = ({\n icon,\n description,\n onClick,\n type = 'default',\n shape = 'circle',\n className = '',\n tooltip,\n tooltipPlacement = 'left',\n badge,\n href,\n target,\n children,\n style,\n 'data-testid': testId,\n ...rest\n}) => {\n const groupContext = useContext(FloatButtonGroupContext)\n const effectiveShape = groupContext.inGroup ? (groupContext.shape || shape) : shape\n\n const buttonClasses = [\n dBtn,\n dBtnLg,\n 'shadow-lg',\n shapeClasses[effectiveShape],\n typeClasses[type],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const content = icon || children || <PlusIcon />\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n const buttonContent = (\n <>\n {description ? (\n <div className=\"flex flex-col items-center\">\n {content}\n <span className=\"text-xs mt-1\">{description}</span>\n </div>\n ) : (\n content\n )}\n </>\n )\n\n // When inside a group, render simple button without wrapper divs\n // DaisyUI's fab CSS requires direct button children\n if (groupContext.inGroup) {\n return href ? (\n <a\n href={href}\n target={target}\n className={buttonClasses}\n title={tooltip}\n onClick={onClick as any}\n data-testid={testId}\n {...(rest as any)}\n >\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} title={tooltip} onClick={onClick} data-testid={testId} {...rest}>\n {buttonContent}\n </button>\n )\n }\n\n const buttonElement = href ? (\n <a\n href={href}\n target={target}\n className={buttonClasses}\n style={style}\n onClick={onClick as any}\n data-testid={testId}\n {...(rest as any)}\n >\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} onClick={onClick} style={style} data-testid={testId} {...rest}>\n {buttonContent}\n </button>\n )\n\n const withBadge = badge !== undefined ? (\n <div className={dIndicator} style={style} data-testid={getTestId('indicator')}>\n <span className={`${dIndicatorItem} ${dBadge} ${dBadgeSecondary}`} data-testid={getTestId('badge')}>\n {badge}\n </span>\n {href ? (\n <a\n href={href}\n target={target}\n className={buttonClasses}\n onClick={onClick as any}\n data-testid={testId}\n {...(rest as any)}\n >\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} onClick={onClick} data-testid={testId} {...rest}>\n {buttonContent}\n </button>\n )}\n </div>\n ) : buttonElement\n\n if (tooltip) {\n return (\n <div\n className={`${dTooltip} ${tooltipPlacementClasses[tooltipPlacement]}`}\n data-tip={tooltip}\n style={style}\n data-testid={getTestId('tooltip')}\n >\n {badge !== undefined ? (\n <div className={dIndicator}>\n <span className={`${dIndicatorItem} ${dBadge} ${dBadgeSecondary}`} data-testid={getTestId('badge')}>{badge}</span>\n {href ? (\n <a\n href={href}\n target={target}\n className={buttonClasses}\n onClick={onClick as any}\n data-testid={testId}\n {...(rest as any)}\n >\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} onClick={onClick} data-testid={testId} {...rest}>\n {buttonContent}\n </button>\n )}\n </div>\n ) : href ? (\n <a\n href={href}\n target={target}\n className={buttonClasses}\n onClick={onClick as any}\n data-testid={testId}\n {...(rest as any)}\n >\n {buttonContent}\n </a>\n ) : (\n <button className={buttonClasses} onClick={onClick} data-testid={testId} {...rest}>\n {buttonContent}\n </button>\n )}\n </div>\n )\n }\n\n return withBadge\n}\n\nexport const FloatButton: FloatButtonComponent = (props) => {\n const {\n style: propStyle,\n ...rest\n } = props\n\n const groupContext = useContext(FloatButtonGroupContext)\n\n // If in group, don't apply fixed positioning\n if (groupContext.inGroup) {\n return <FloatButtonBase {...rest} />\n }\n\n // Standalone button with fixed positioning\n const style: React.CSSProperties = {\n position: 'fixed',\n zIndex: 1000,\n bottom: 24,\n right: 24,\n ...propStyle,\n }\n\n return <FloatButtonBase {...rest} style={style} />\n}\n\nconst FloatButtonGroup: React.FC<FloatButtonGroupProps> = ({\n children,\n flower = false,\n shape = 'circle',\n icon,\n triggerLabel = 'Open menu',\n mainAction,\n mainActionLabel,\n onMainAction,\n showClose = false,\n closeLabel = 'Close menu',\n type = 'default',\n position = 'bottom-right',\n offset = 24,\n className = '',\n style: propStyle,\n 'data-testid': testId,\n}) => {\n const fabClasses = [\n dFab,\n flower ? dFabFlower : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const triggerButtonClasses = [\n dBtn,\n dBtnLg,\n 'shadow-lg',\n shapeClasses[shape],\n typeClasses[type],\n ]\n .filter(Boolean)\n .join(' ')\n\n const containerStyle: React.CSSProperties = {\n ...(position.includes('bottom') ? { bottom: offset } : { top: offset }),\n ...(position.includes('right') ? { right: offset } : { left: offset }),\n ...propStyle,\n }\n\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n return (\n <div className={fabClasses} style={containerStyle} data-testid={testId}>\n {/* Trigger button - shown when closed */}\n <button\n type=\"button\"\n className={triggerButtonClasses}\n aria-label={triggerLabel}\n aria-haspopup=\"true\"\n data-testid={getTestId('trigger')}\n >\n {icon || <PlusIcon />}\n </button>\n\n {/* Main action button - shown when open (replaces trigger in flower mode) */}\n {mainAction && (\n <button\n type=\"button\"\n className={`${triggerButtonClasses} ${dFabMainAction}`}\n onClick={onMainAction}\n aria-label={mainActionLabel}\n data-testid={getTestId('main-action')}\n >\n {mainAction}\n </button>\n )}\n\n {/* Close button - shown when open */}\n {showClose && (\n <button\n type=\"button\"\n className={`${triggerButtonClasses} ${dFabClose}`}\n aria-label={closeLabel}\n data-testid={getTestId('close')}\n >\n <CloseIcon />\n </button>\n )}\n\n <FloatButtonGroupContext.Provider value={{ inGroup: true, shape }}>\n {children}\n </FloatButtonGroupContext.Provider>\n </div>\n )\n}\n\nconst BackTop: React.FC<BackTopProps> = ({\n visibilityHeight = 400,\n target,\n onClick,\n icon,\n duration = 450,\n position = 'bottom-right',\n offset = 24,\n className = '',\n children,\n style: propStyle,\n 'data-testid': testId,\n ...rest\n}) => {\n const [visible, setVisible] = useState(false)\n\n useEffect(() => {\n const scrollTarget = target ? target() : window\n\n const handleScroll = () => {\n const scrollTop =\n scrollTarget instanceof Window\n ? window.scrollY\n : (scrollTarget as HTMLElement).scrollTop\n\n setVisible(scrollTop >= visibilityHeight)\n }\n\n scrollTarget.addEventListener('scroll', handleScroll)\n handleScroll()\n\n return () => scrollTarget.removeEventListener('scroll', handleScroll)\n }, [target, visibilityHeight])\n\n const handleClick = () => {\n onClick?.()\n const scrollTarget = target ? target() : window\n if (scrollTarget instanceof Window) {\n window.scrollTo({ top: 0, behavior: 'smooth' })\n } else {\n (scrollTarget as HTMLElement).scrollTo({ top: 0, behavior: 'smooth' })\n }\n }\n\n if (!visible) return null\n\n const buttonClasses = [\n dBtn,\n dBtnLg,\n dBtnCircle,\n dBtnNeutral,\n 'shadow-lg',\n 'transition-opacity',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const style: React.CSSProperties = {\n position: 'fixed',\n zIndex: 1000,\n bottom: offset,\n ...(position.includes('right') ? { right: offset } : { left: offset }),\n ...propStyle,\n }\n\n return (\n <button\n className={buttonClasses}\n onClick={handleClick}\n style={style}\n aria-label={rest['aria-label'] || 'Back to top'}\n data-testid={testId}\n {...rest}\n >\n {icon || children || <ArrowUpIcon />}\n </button>\n )\n}\n\nFloatButton.Group = FloatButtonGroup\nFloatButton.BackTop = BackTop\n"],"names":["dBtn","dBtnLg","dBtnCircle","dBtnSquare","dBtnNeutral","dBtnPrimary","dTooltip","dTooltipLeft","dTooltipRight","dTooltipTop","dTooltipBottom","dIndicator","dIndicatorItem","dBadge","dBadgeSecondary","dFab","dFabFlower","dFabMainAction","dFabClose","PlusIcon","jsx","ArrowUpIcon","CloseIcon","FloatButtonGroupContext","createContext","tooltipPlacementClasses","typeClasses","shapeClasses","FloatButtonBase","icon","description","onClick","type","shape","className","tooltip","tooltipPlacement","badge","href","target","children","style","testId","rest","groupContext","useContext","effectiveShape","buttonClasses","content","getTestId","suffix","buttonContent","Fragment","jsxs","buttonElement","withBadge","FloatButton","props","propStyle","FloatButtonGroup","flower","triggerLabel","mainAction","mainActionLabel","onMainAction","showClose","closeLabel","position","offset","fabClasses","triggerButtonClasses","containerStyle","BackTop","visibilityHeight","duration","visible","setVisible","useState","useEffect","scrollTarget","handleScroll","scrollTop","handleClick"],"mappings":";;AAGA,MAAMA,IAAO,OACPC,IAAS,UACTC,IAAa,cACbC,IAAa,cACbC,IAAc,eACdC,IAAc,eACdC,IAAW,WACXC,IAAe,gBACfC,IAAgB,iBAChBC,IAAc,eACdC,IAAiB,kBACjBC,IAAa,aACbC,IAAiB,kBACjBC,IAAS,SACTC,IAAkB,mBAClBC,IAAO,OACPC,IAAa,cACbC,KAAiB,mBACjBC,KAAY,aAGZC,IAAW,MACf,gBAAAC,EAAC,OAAA,EAAI,OAAM,8BAA6B,WAAU,WAAU,MAAK,QAAO,SAAQ,aAAY,QAAO,gBACjG,UAAA,gBAAA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AAA,IACA;AAAA,IACA;AAAA,IACA8B;AAAA,EAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG,GAELO,IAA6B;AAAA,IACjC,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,QAAQ2B;AAAA,IACR,GAAID,EAAS,SAAS,OAAO,IAAI,EAAE,OAAOC,EAAA,IAAW,EAAE,MAAMA,EAAA;AAAA,IAC7D,GAAGV;AAAA,EAAA;AAGL,SACE,gBAAAtC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW2B;AAAA,MACX,SAASmC;AAAA,MACT,OAAAzC;AAAA,MACA,cAAYE,EAAK,YAAY,KAAK;AAAA,MAClC,eAAaD;AAAA,MACZ,GAAGC;AAAA,MAEH,UAAAd,KAAQW,KAAY,gBAAApB,EAACC,IAAA,CAAA,CAAY;AAAA,IAAA;AAAA,EAAA;AAGxC;AAEAmC,EAAY,QAAQG;AACpBH,EAAY,UAAUgB;"}
|
|
@@ -32,5 +32,6 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
32
32
|
errorId?: string;
|
|
33
33
|
/** Render as unstyled input (for use inside styled wrappers) */
|
|
34
34
|
unstyled?: boolean;
|
|
35
|
+
'data-testid'?: string;
|
|
35
36
|
}
|
|
36
37
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
package/dist/components/Input.js
CHANGED
|
@@ -1,263 +1,280 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
let
|
|
7
|
-
for (let f = 0; f <
|
|
8
|
-
const x =
|
|
9
|
-
x === "#" || x === "A" || x === "*" ? o < e.length ? (
|
|
1
|
+
import { jsx as l, jsxs as Z } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Wt, useRef as $t, useCallback as M, useState as K, useEffect as P } from "react";
|
|
3
|
+
import { useConfig as Ft } from "../providers/ConfigProvider.js";
|
|
4
|
+
const G = "input", dt = "input-xs", pt = "input-sm", ft = "input-md", ht = "input-lg", gt = "input-xl", Ut = "input-neutral", Xt = "input-primary", Zt = "input-secondary", Gt = "input-accent", Lt = "input-info", _t = "input-success", It = "input-warning", xt = "input-error", Dt = "input-ghost", Ht = "floating-label";
|
|
5
|
+
function m(e, i, s) {
|
|
6
|
+
let u = "", o = 0;
|
|
7
|
+
for (let f = 0; f < i.length && o <= e.length; f++) {
|
|
8
|
+
const x = i[f];
|
|
9
|
+
x === "#" || x === "A" || x === "*" ? o < e.length ? (u += e[o], o++) : u += s : u += x;
|
|
10
10
|
}
|
|
11
|
-
return
|
|
11
|
+
return u;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
let
|
|
15
|
-
for (let o = 0; o < e.length && o <
|
|
16
|
-
const f =
|
|
17
|
-
(f === "#" || f === "A" || f === "*") && e[o] !==
|
|
13
|
+
function k(e, i, s) {
|
|
14
|
+
let u = "";
|
|
15
|
+
for (let o = 0; o < e.length && o < i.length; o++) {
|
|
16
|
+
const f = i[o];
|
|
17
|
+
(f === "#" || f === "A" || f === "*") && e[o] !== s && (u += e[o]);
|
|
18
18
|
}
|
|
19
|
-
return
|
|
19
|
+
return u;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function Jt(e, i) {
|
|
22
|
+
return i === "#" ? /\d/.test(e) : i === "A" ? /[a-zA-Z]/.test(e) : i === "*" ? /[a-zA-Z0-9]/.test(e) : !1;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
for (let
|
|
26
|
-
if (e[
|
|
27
|
-
return
|
|
24
|
+
function wt(e, i) {
|
|
25
|
+
for (let s = i; s < e.length; s++)
|
|
26
|
+
if (e[s] === "#" || e[s] === "A" || e[s] === "*")
|
|
27
|
+
return s;
|
|
28
28
|
return e.length;
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const Ot = ({ onClick: e, className: i }) => /* @__PURE__ */ l(
|
|
31
31
|
"button",
|
|
32
32
|
{
|
|
33
33
|
type: "button",
|
|
34
34
|
onClick: e,
|
|
35
|
-
className: `flex items-center justify-center opacity-50 hover:opacity-100 transition-opacity ${
|
|
35
|
+
className: `flex items-center justify-center opacity-50 hover:opacity-100 transition-opacity ${i || ""}`,
|
|
36
36
|
"aria-label": "Clear input",
|
|
37
37
|
tabIndex: -1,
|
|
38
|
-
children: /* @__PURE__ */
|
|
38
|
+
children: /* @__PURE__ */ l("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ l("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
39
39
|
}
|
|
40
|
-
),
|
|
40
|
+
), Qt = Wt(
|
|
41
41
|
({
|
|
42
42
|
type: e = "text",
|
|
43
|
-
size:
|
|
44
|
-
color:
|
|
45
|
-
status:
|
|
43
|
+
size: i,
|
|
44
|
+
color: s,
|
|
45
|
+
status: u,
|
|
46
46
|
ghost: o = !1,
|
|
47
47
|
bordered: f = !0,
|
|
48
48
|
className: x = "",
|
|
49
49
|
mask: t,
|
|
50
|
-
maskPlaceholder:
|
|
51
|
-
allowClear:
|
|
52
|
-
onClear:
|
|
53
|
-
prefix:
|
|
54
|
-
suffix:
|
|
55
|
-
addonBefore:
|
|
56
|
-
addonAfter:
|
|
57
|
-
floatingLabel:
|
|
58
|
-
errorId:
|
|
59
|
-
unstyled:
|
|
50
|
+
maskPlaceholder: p = "_",
|
|
51
|
+
allowClear: R,
|
|
52
|
+
onClear: tt,
|
|
53
|
+
prefix: T,
|
|
54
|
+
suffix: j,
|
|
55
|
+
addonBefore: L,
|
|
56
|
+
addonAfter: _,
|
|
57
|
+
floatingLabel: C,
|
|
58
|
+
errorId: nt,
|
|
59
|
+
unstyled: yt = !1,
|
|
60
60
|
value: r,
|
|
61
|
-
defaultValue:
|
|
62
|
-
onChange:
|
|
63
|
-
onKeyDown:
|
|
64
|
-
disabled:
|
|
65
|
-
required:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
61
|
+
defaultValue: V,
|
|
62
|
+
onChange: a,
|
|
63
|
+
onKeyDown: z,
|
|
64
|
+
disabled: D,
|
|
65
|
+
required: H,
|
|
66
|
+
"data-testid": w,
|
|
67
|
+
...et
|
|
68
|
+
}, bt) => {
|
|
69
|
+
const { componentSize: vt } = Ft(), J = i ?? vt ?? "md", rt = {
|
|
70
|
+
xs: dt,
|
|
71
|
+
sm: pt,
|
|
72
|
+
md: ft,
|
|
73
|
+
lg: ht,
|
|
74
|
+
xl: gt
|
|
75
|
+
}, it = u ? {
|
|
76
|
+
error: xt,
|
|
77
|
+
warning: It
|
|
78
|
+
}[u] : s ? {
|
|
79
|
+
neutral: Ut,
|
|
80
|
+
primary: Xt,
|
|
81
|
+
secondary: Zt,
|
|
82
|
+
accent: Gt,
|
|
83
|
+
info: Lt,
|
|
84
|
+
success: _t,
|
|
85
|
+
warning: It,
|
|
86
|
+
error: xt
|
|
87
|
+
}[s] : "", W = L || _, Ct = W || yt ? ["grow", "bg-transparent", "border-0", "outline-none", "focus:outline-none", x].filter(Boolean).join(" ") : [
|
|
88
|
+
G,
|
|
88
89
|
!f && "border-0",
|
|
89
|
-
o &&
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
o && Dt,
|
|
91
|
+
rt[J],
|
|
92
|
+
it,
|
|
92
93
|
x
|
|
93
|
-
].filter(Boolean).join(" "),
|
|
94
|
-
|
|
95
|
-
t && r !== void 0 &&
|
|
96
|
-
}, [t, r,
|
|
97
|
-
|
|
98
|
-
}, [
|
|
99
|
-
const
|
|
94
|
+
].filter(Boolean).join(" "), Nt = $t(null), h = bt || Nt, At = M(() => t ? k(r ?? V ?? "", t, p) : "", [t, r, V, p]), [$, F] = K(At), [U, O] = K(null);
|
|
95
|
+
P(() => {
|
|
96
|
+
t && r !== void 0 && F(k(r, t, p));
|
|
97
|
+
}, [t, r, p]), P(() => {
|
|
98
|
+
U !== null && h.current && (h.current.setSelectionRange(U, U), O(null));
|
|
99
|
+
}, [U, h]);
|
|
100
|
+
const st = M(
|
|
100
101
|
(n) => {
|
|
101
102
|
if (!t) {
|
|
102
|
-
|
|
103
|
+
a?.(n);
|
|
103
104
|
return;
|
|
104
105
|
}
|
|
105
|
-
const
|
|
106
|
-
let
|
|
107
|
-
for (let
|
|
108
|
-
const I = t[
|
|
109
|
-
(I === "#" || I === "A" || I === "*") && (
|
|
106
|
+
const d = n.target, B = d.value, N = k(B, t, p);
|
|
107
|
+
let b = "", v = 0;
|
|
108
|
+
for (let g = 0; g < t.length && v < N.length; g++) {
|
|
109
|
+
const I = t[g];
|
|
110
|
+
(I === "#" || I === "A" || I === "*") && (Jt(N[v], I) && (b += N[v]), v++);
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
let c =
|
|
114
|
-
for (let
|
|
115
|
-
const I = t[
|
|
116
|
-
(I === "#" || I === "A" || I === "*") &&
|
|
112
|
+
F(b);
|
|
113
|
+
const X = m(b, t, p);
|
|
114
|
+
let c = wt(t, 0), A = 0;
|
|
115
|
+
for (let g = 0; g < t.length; g++) {
|
|
116
|
+
const I = t[g];
|
|
117
|
+
(I === "#" || I === "A" || I === "*") && A < b.length && (A++, c = g + 1);
|
|
117
118
|
}
|
|
118
|
-
c =
|
|
119
|
-
const
|
|
119
|
+
c = wt(t, c), c > t.length && (c = t.length), O(c);
|
|
120
|
+
const Tt = {
|
|
120
121
|
...n,
|
|
121
|
-
target: { ...
|
|
122
|
-
currentTarget: { ...
|
|
122
|
+
target: { ...d, value: X },
|
|
123
|
+
currentTarget: { ...d, value: X }
|
|
123
124
|
};
|
|
124
|
-
|
|
125
|
+
a?.(Tt);
|
|
125
126
|
},
|
|
126
|
-
[t,
|
|
127
|
-
),
|
|
127
|
+
[t, p, a]
|
|
128
|
+
), ot = M(
|
|
128
129
|
(n) => {
|
|
129
130
|
if (!t) {
|
|
130
|
-
|
|
131
|
+
z?.(n);
|
|
131
132
|
return;
|
|
132
133
|
}
|
|
133
134
|
if (n.key === "Backspace") {
|
|
134
135
|
n.preventDefault();
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
let
|
|
136
|
+
const d = $.slice(0, -1);
|
|
137
|
+
F(d);
|
|
138
|
+
let B = 0, N = 0;
|
|
138
139
|
for (let c = 0; c < t.length; c++) {
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
142
|
-
|
|
140
|
+
const A = t[c];
|
|
141
|
+
if (A === "#" || A === "A" || A === "*")
|
|
142
|
+
if (N < d.length)
|
|
143
|
+
N++, B = c + 1;
|
|
143
144
|
else {
|
|
144
|
-
|
|
145
|
+
B = c;
|
|
145
146
|
break;
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
target: { ...
|
|
151
|
-
currentTarget: { ...
|
|
149
|
+
O(B);
|
|
150
|
+
const b = m(d, t, p), v = n.currentTarget, X = {
|
|
151
|
+
target: { ...v, value: b },
|
|
152
|
+
currentTarget: { ...v, value: b }
|
|
152
153
|
};
|
|
153
|
-
|
|
154
|
+
a?.(X);
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
+
z?.(n);
|
|
156
157
|
},
|
|
157
|
-
[t,
|
|
158
|
-
), [
|
|
159
|
-
|
|
160
|
-
r !== void 0 &&
|
|
158
|
+
[t, p, $, a, z]
|
|
159
|
+
), [Q, Y] = K(r ?? V ?? "");
|
|
160
|
+
P(() => {
|
|
161
|
+
r !== void 0 && Y(r);
|
|
161
162
|
}, [r]);
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
}, [
|
|
165
|
-
if (
|
|
163
|
+
const ct = M((n) => {
|
|
164
|
+
Y(n.target.value), a?.(n);
|
|
165
|
+
}, [a]), Rt = M(() => {
|
|
166
|
+
if (Y(""), F(""), tt?.(), a && h.current) {
|
|
166
167
|
const n = {
|
|
167
|
-
target: { ...
|
|
168
|
-
currentTarget: { ...
|
|
168
|
+
target: { ...h.current, value: "" },
|
|
169
|
+
currentTarget: { ...h.current, value: "" }
|
|
169
170
|
};
|
|
170
|
-
|
|
171
|
+
a(n);
|
|
171
172
|
}
|
|
172
|
-
}, [
|
|
173
|
-
|
|
174
|
-
const T =
|
|
175
|
-
xs:
|
|
176
|
-
sm:
|
|
177
|
-
md:
|
|
178
|
-
lg:
|
|
179
|
-
xl:
|
|
180
|
-
},
|
|
173
|
+
}, [tt, a, h]), q = R && (t ? $ : Q) && !D, jt = typeof R == "object" && R.clearIcon ? R.clearIcon : null, E = {};
|
|
174
|
+
u === "error" && (E["aria-invalid"] = !0), nt && (E["aria-describedby"] = nt), H && (E["aria-required"] = !0);
|
|
175
|
+
const S = T || j || R, Vt = S || W || !!C, y = (n) => w ? `${w}-${n}` : void 0, lt = w ? Vt ? y("input") : w : void 0, zt = {
|
|
176
|
+
xs: dt,
|
|
177
|
+
sm: pt,
|
|
178
|
+
md: ft,
|
|
179
|
+
lg: ht,
|
|
180
|
+
xl: gt
|
|
181
|
+
}, ut = t ? m($, t, p) : void 0, at = (n) => /* @__PURE__ */ l(
|
|
181
182
|
"input",
|
|
182
183
|
{
|
|
183
|
-
ref:
|
|
184
|
+
ref: h,
|
|
184
185
|
type: t ? "text" : e,
|
|
185
186
|
className: [
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
(
|
|
187
|
+
Ct,
|
|
188
|
+
S && "w-full",
|
|
189
|
+
T && "pl-10",
|
|
190
|
+
(j || q) && "pr-10",
|
|
190
191
|
n
|
|
191
192
|
].filter(Boolean).join(" "),
|
|
192
|
-
value:
|
|
193
|
-
defaultValue: r === void 0 && !t ?
|
|
194
|
-
onChange: t ?
|
|
195
|
-
onKeyDown: t ?
|
|
196
|
-
disabled:
|
|
197
|
-
required:
|
|
198
|
-
|
|
199
|
-
...
|
|
193
|
+
value: ut ?? (r !== void 0 ? r : S ? Q : r),
|
|
194
|
+
defaultValue: r === void 0 && !t ? V : void 0,
|
|
195
|
+
onChange: t ? st : S ? ct : a,
|
|
196
|
+
onKeyDown: t ? ot : z,
|
|
197
|
+
disabled: D,
|
|
198
|
+
required: H,
|
|
199
|
+
"data-testid": lt,
|
|
200
|
+
...E,
|
|
201
|
+
...et
|
|
200
202
|
}
|
|
201
|
-
),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
203
|
+
), Et = (n) => S ? /* @__PURE__ */ Z(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
className: `relative flex items-center ${n || ""}`,
|
|
207
|
+
"data-testid": !W && !C ? w : y("input-wrapper"),
|
|
208
|
+
children: [
|
|
209
|
+
T && /* @__PURE__ */ l(
|
|
210
|
+
"span",
|
|
211
|
+
{
|
|
212
|
+
className: "absolute left-3 flex items-center text-base-content/70 pointer-events-none z-10",
|
|
213
|
+
"data-testid": y("prefix"),
|
|
214
|
+
children: T
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
at(),
|
|
218
|
+
(j || q) && /* @__PURE__ */ Z("span", { className: "absolute right-3 flex items-center gap-1 z-10", "data-testid": y("suffix"), children: [
|
|
219
|
+
q && /* @__PURE__ */ l("span", { "data-testid": y("clear"), children: jt || /* @__PURE__ */ l(Ot, { onClick: Rt }) }),
|
|
220
|
+
j && /* @__PURE__ */ l("span", { className: "text-base-content/70", children: j })
|
|
221
|
+
] })
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
) : at(n), St = (n) => {
|
|
225
|
+
if (!C) return n;
|
|
226
|
+
const d = [
|
|
227
|
+
Ht,
|
|
228
|
+
zt[J]
|
|
213
229
|
].filter(Boolean).join(" ");
|
|
214
|
-
return /* @__PURE__ */
|
|
230
|
+
return /* @__PURE__ */ Z("label", { className: d, "data-testid": w, children: [
|
|
215
231
|
n,
|
|
216
|
-
/* @__PURE__ */
|
|
232
|
+
/* @__PURE__ */ l("span", { children: C })
|
|
217
233
|
] });
|
|
218
|
-
},
|
|
219
|
-
if (!
|
|
220
|
-
const
|
|
221
|
-
|
|
234
|
+
}, Bt = (n) => {
|
|
235
|
+
if (!W) return n;
|
|
236
|
+
const d = [
|
|
237
|
+
G,
|
|
222
238
|
"flex",
|
|
223
239
|
"items-center",
|
|
224
240
|
"gap-2",
|
|
225
|
-
|
|
226
|
-
|
|
241
|
+
rt[J],
|
|
242
|
+
it
|
|
227
243
|
].filter(Boolean).join(" ");
|
|
228
|
-
return /* @__PURE__ */
|
|
229
|
-
|
|
244
|
+
return /* @__PURE__ */ Z("label", { className: d, "data-testid": w, children: [
|
|
245
|
+
L && /* @__PURE__ */ l("span", { className: "text-base-content/70", "data-testid": y("addon-before"), children: L }),
|
|
230
246
|
n,
|
|
231
|
-
|
|
247
|
+
_ && /* @__PURE__ */ l("span", { className: "text-base-content/70", "data-testid": y("addon-after"), children: _ })
|
|
232
248
|
] });
|
|
233
|
-
},
|
|
234
|
-
|
|
249
|
+
}, Mt = Et(
|
|
250
|
+
C ? `${G} w-full` : void 0
|
|
235
251
|
);
|
|
236
|
-
return
|
|
237
|
-
|
|
252
|
+
return Bt(St(
|
|
253
|
+
C ? (
|
|
238
254
|
// For floating label, use raw input (label wrapper provides styling)
|
|
239
|
-
/* @__PURE__ */
|
|
255
|
+
/* @__PURE__ */ l(
|
|
240
256
|
"input",
|
|
241
257
|
{
|
|
242
|
-
ref:
|
|
258
|
+
ref: h,
|
|
243
259
|
type: t ? "text" : e,
|
|
244
|
-
className: `${
|
|
245
|
-
value:
|
|
246
|
-
defaultValue: r === void 0 && !t ?
|
|
247
|
-
onChange: t ?
|
|
248
|
-
onKeyDown: t ?
|
|
249
|
-
disabled:
|
|
250
|
-
required:
|
|
251
|
-
|
|
252
|
-
...
|
|
260
|
+
className: `${G} w-full`,
|
|
261
|
+
value: ut ?? (r !== void 0 ? r : Q),
|
|
262
|
+
defaultValue: r === void 0 && !t ? V : void 0,
|
|
263
|
+
onChange: t ? st : ct,
|
|
264
|
+
onKeyDown: t ? ot : z,
|
|
265
|
+
disabled: D,
|
|
266
|
+
required: H,
|
|
267
|
+
"data-testid": lt,
|
|
268
|
+
...E,
|
|
269
|
+
...et
|
|
253
270
|
}
|
|
254
271
|
)
|
|
255
|
-
) :
|
|
272
|
+
) : Mt
|
|
256
273
|
));
|
|
257
274
|
}
|
|
258
275
|
);
|
|
259
|
-
|
|
276
|
+
Qt.displayName = "Input";
|
|
260
277
|
export {
|
|
261
|
-
|
|
278
|
+
Qt as Input
|
|
262
279
|
};
|
|
263
280
|
//# sourceMappingURL=Input.js.map
|