@brycks/core-front 0.3.2 → 0.3.4
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/feedback/Alert/Alert.cjs +1 -1
- package/dist/components/feedback/Alert/Alert.cjs.map +1 -1
- package/dist/components/feedback/Alert/Alert.js +52 -177
- package/dist/components/feedback/Alert/Alert.js.map +1 -1
- package/dist/components/feedback/Modal/Modal.cjs +1 -1
- package/dist/components/feedback/Modal/Modal.cjs.map +1 -1
- package/dist/components/feedback/Modal/Modal.js +7 -6
- package/dist/components/feedback/Modal/Modal.js.map +1 -1
- package/dist/components/form/Checkbox/Checkbox.cjs +1 -1
- package/dist/components/form/Checkbox/Checkbox.js +12 -12
- package/dist/components/form/Input/Input.cjs +1 -1
- package/dist/components/form/Input/Input.js +13 -13
- package/dist/components/form/Slider/Slider.cjs +1 -1
- package/dist/components/form/Slider/Slider.js +1 -1
- package/dist/components/form/Switch/Switch.cjs +1 -1
- package/dist/components/form/Switch/Switch.cjs.map +1 -1
- package/dist/components/form/Switch/Switch.js +70 -105
- package/dist/components/form/Switch/Switch.js.map +1 -1
- package/dist/components/layout/Card/Card.cjs +1 -1
- package/dist/components/layout/Card/Card.cjs.map +1 -1
- package/dist/components/layout/Card/Card.js +59 -121
- package/dist/components/layout/Card/Card.js.map +1 -1
- package/dist/components/navigation/Dropdown/Dropdown.cjs +1 -6
- package/dist/components/navigation/Dropdown/Dropdown.cjs.map +1 -1
- package/dist/components/navigation/Dropdown/Dropdown.js +118 -183
- package/dist/components/navigation/Dropdown/Dropdown.js.map +1 -1
- package/dist/components/navigation/Menu/Menu.cjs +1 -1
- package/dist/components/navigation/Menu/Menu.js +5 -5
- package/dist/components/navigation/Tabs/Tabs.cjs +1 -6
- package/dist/components/navigation/Tabs/Tabs.cjs.map +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +92 -162
- package/dist/components/navigation/Tabs/Tabs.js.map +1 -1
- package/dist/components/primitives/Button/Button.cjs +1 -1
- package/dist/components/primitives/Button/Button.cjs.map +1 -1
- package/dist/components/primitives/Button/Button.js +72 -96
- package/dist/components/primitives/Button/Button.js.map +1 -1
- package/dist/components/primitives/Button/Button.styles.cjs +1 -1
- package/dist/components/primitives/Button/Button.styles.cjs.map +1 -1
- package/dist/components/primitives/Button/Button.styles.js +8 -317
- package/dist/components/primitives/Button/Button.styles.js.map +1 -1
- package/dist/components/utility/Badge/Badge.cjs +1 -1
- package/dist/components/utility/Badge/Badge.cjs.map +1 -1
- package/dist/components/utility/Badge/Badge.js +23 -80
- package/dist/components/utility/Badge/Badge.js.map +1 -1
- package/dist/feedback.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":["../../../../src/components/feedback/Modal/Modal.tsx"],"sourcesContent":["/**\r\n * Modal Component\r\n *\r\n * Accessible modal dialog with smooth Apple-inspired animations.\r\n * Supports focus trapping and keyboard navigation.\r\n */\r\n\r\nimport {\r\n forwardRef,\r\n useEffect,\r\n useRef,\r\n useCallback,\r\n useMemo,\r\n memo,\r\n type CSSProperties,\r\n type ReactNode,\r\n type HTMLAttributes,\r\n} from 'react'\r\nimport { createPortal } from 'react-dom'\r\nimport { cx } from '../../../utils/styles'\r\nimport { spacing, fontSizes } from '../../../design-system'\r\nimport { componentGap, iconButtonSizes } from '../../../design-system/primitives'\r\n\r\nexport type ModalSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'\r\n\r\nexport interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\r\n /** Whether the modal is open */\r\n isOpen: boolean\r\n /** Callback when modal should close */\r\n onClose: () => void\r\n /** Modal size */\r\n size?: ModalSize\r\n /** Modal title */\r\n title?: ReactNode\r\n /** Modal description */\r\n description?: ReactNode\r\n /** Whether to close on overlay click */\r\n closeOnOverlayClick?: boolean\r\n /** Whether to close on escape key */\r\n closeOnEscape?: boolean\r\n /** Whether to show close button */\r\n showCloseButton?: boolean\r\n /** Custom class name */\r\n className?: string\r\n /** Test ID */\r\n testId?: string\r\n /** Modal content */\r\n children?: ReactNode\r\n}\r\n\r\nconst sizeWidths: Record<ModalSize, string> = {\r\n sm: '400px',\r\n md: '500px',\r\n lg: '640px',\r\n xl: '800px',\r\n full: 'calc(100vw - 48px)',\r\n}\r\n\r\n/** Close icon - memoized to prevent re-renders */\r\nconst CloseIcon = memo(function CloseIcon() {\r\n return (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\r\n <path\r\n d=\"M4 4L12 12M12 4L4 12\"\r\n stroke=\"currentColor\"\r\n strokeWidth=\"1.5\"\r\n strokeLinecap=\"round\"\r\n />\r\n </svg>\r\n )\r\n})\r\n\r\nexport const Modal = forwardRef<HTMLDivElement, ModalProps>(function Modal(\r\n {\r\n isOpen,\r\n onClose,\r\n size = 'md',\r\n title,\r\n description,\r\n closeOnOverlayClick = true,\r\n closeOnEscape = true,\r\n showCloseButton = true,\r\n className,\r\n style,\r\n testId,\r\n children,\r\n ...props\r\n },\r\n ref\r\n) {\r\n const modalRef = useRef<HTMLDivElement>(null)\r\n const previousActiveElement = useRef<HTMLElement | null>(null)\r\n const wasOpen = useRef(false)\r\n\r\n // Track previous open state to handle focus restoration before unmount\r\n useEffect(() => {\r\n // Modal just opened\r\n if (isOpen && !wasOpen.current) {\r\n previousActiveElement.current = document.activeElement as HTMLElement\r\n wasOpen.current = true\r\n }\r\n // Modal is about to close - restore focus BEFORE unmount\r\n else if (!isOpen && wasOpen.current) {\r\n // Blur any focused element inside modal to prevent aria-hidden warning\r\n if (document.activeElement instanceof HTMLElement) {\r\n document.activeElement.blur()\r\n }\r\n // Restore focus to previous element\r\n previousActiveElement.current?.focus()\r\n previousActiveElement.current = null\r\n wasOpen.current = false\r\n }\r\n }, [isOpen])\r\n\r\n // Store onClose in a ref to avoid re-running effects when it changes\r\n const onCloseRef = useRef(onClose)\r\n useEffect(() => {\r\n onCloseRef.current = onClose\r\n }, [onClose])\r\n\r\n // Focus modal when it opens (only once)\r\n useEffect(() => {\r\n if (!isOpen) return\r\n\r\n const modal = modalRef.current\r\n if (modal) {\r\n modal.focus()\r\n }\r\n }, [isOpen])\r\n\r\n // Keyboard handling and body scroll lock\r\n useEffect(() => {\r\n if (!isOpen) return\r\n\r\n const modal = modalRef.current\r\n\r\n const handleKeyDown = (e: KeyboardEvent) => {\r\n if (e.key === 'Escape' && closeOnEscape) {\r\n onCloseRef.current()\r\n return\r\n }\r\n\r\n if (e.key === 'Tab' && modal) {\r\n const focusableElements = modal.querySelectorAll<HTMLElement>(\r\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\r\n )\r\n const firstElement = focusableElements[0]\r\n const lastElement = focusableElements[focusableElements.length - 1]\r\n\r\n if (e.shiftKey && document.activeElement === firstElement) {\r\n e.preventDefault()\r\n lastElement?.focus()\r\n } else if (!e.shiftKey && document.activeElement === lastElement) {\r\n e.preventDefault()\r\n firstElement?.focus()\r\n }\r\n }\r\n }\r\n\r\n document.addEventListener('keydown', handleKeyDown)\r\n document.body.style.overflow = 'hidden'\r\n\r\n return () => {\r\n document.removeEventListener('keydown', handleKeyDown)\r\n document.body.style.overflow = ''\r\n }\r\n }, [isOpen, closeOnEscape])\r\n\r\n const handleOverlayClick = useCallback(\r\n (e: React.MouseEvent) => {\r\n if (e.target === e.currentTarget && closeOnOverlayClick) {\r\n onClose()\r\n }\r\n },\r\n [closeOnOverlayClick, onClose]\r\n )\r\n\r\n // Memoize styles to prevent object recreation on every render\r\n const overlayStyle = useMemo<CSSProperties>(() => ({\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 'var(--brycks-z-modal)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: spacing[6],\r\n backgroundColor: 'var(--brycks-background-overlay)',\r\n backdropFilter: 'blur(4px)',\r\n animation: 'brycks-fade-in var(--brycks-duration-normal) var(--brycks-ease-out)',\r\n }), [])\r\n\r\n const modalStyle = useMemo<CSSProperties>(() => ({\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: sizeWidths[size],\r\n maxHeight: size === 'full' ? 'calc(100vh - 48px)' : '85vh',\r\n backgroundColor: 'var(--brycks-background-elevated)',\r\n borderRadius: 'var(--brycks-radius-xl)',\r\n boxShadow: 'var(--brycks-shadow-2xl)',\r\n display: 'flex',\r\n flexDirection: 'column',\r\n overflow: 'hidden',\r\n animation: 'brycks-scale-in var(--brycks-duration-normal) var(--brycks-ease-spring)',\r\n outline: 'none',\r\n ...style,\r\n }), [size, style])\r\n\r\n if (!isOpen) return null\r\n\r\n const headerStyle: CSSProperties = {\r\n display: 'flex',\r\n alignItems: 'flex-start',\r\n justifyContent: 'space-between',\r\n padding: `${spacing[5]}px ${spacing[6]}px`,\r\n borderBottom: '1px solid var(--brycks-border-muted)',\r\n }\r\n\r\n const titleContainerStyle: CSSProperties = {\r\n display: 'flex',\r\n flexDirection: 'column',\r\n gap: spacing[1],\r\n }\r\n\r\n const titleStyle: CSSProperties = {\r\n fontSize: fontSizes.lg,\r\n fontWeight: 600,\r\n color: 'var(--brycks-foreground-default)',\r\n margin: 0,\r\n lineHeight: 1.3,\r\n }\r\n\r\n const descriptionStyle: CSSProperties = {\r\n fontSize: fontSizes.base,\r\n color: 'var(--brycks-foreground-muted)',\r\n margin: 0,\r\n }\r\n\r\n const closeButtonStyle: CSSProperties = {\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n width: iconButtonSizes.sm,\r\n height: iconButtonSizes.sm,\r\n borderRadius: 'var(--brycks-radius-md)',\r\n color: 'var(--brycks-foreground-muted)',\r\n transition: 'all var(--brycks-duration-fast) var(--brycks-ease-out)',\r\n marginLeft: componentGap.xl,\r\n flexShrink: 0,\r\n }\r\n\r\n const contentStyle: CSSProperties = {\r\n flex: 1,\r\n overflow: 'auto',\r\n padding: spacing[6],\r\n }\r\n\r\n const modalContent = (\r\n <div\r\n className=\"brycks-modal-overlay\"\r\n style={overlayStyle}\r\n onClick={handleOverlayClick}\r\n >\r\n <div\r\n ref={(node) => {\r\n (modalRef as React.MutableRefObject<HTMLDivElement | null>).current = node\r\n if (typeof ref === 'function') ref(node)\r\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node\r\n }}\r\n role=\"dialog\"\r\n aria-modal=\"true\"\r\n aria-labelledby={title ? 'brycks-modal-title' : undefined}\r\n aria-describedby={description ? 'brycks-modal-description' : undefined}\r\n className={cx('brycks-modal', `brycks-modal--${size}`, className)}\r\n style={modalStyle}\r\n tabIndex={-1}\r\n data-testid={testId}\r\n {...props}\r\n >\r\n {(title || showCloseButton) && (\r\n <div className=\"brycks-modal-header\" style={headerStyle}>\r\n <div style={titleContainerStyle}>\r\n {title && (\r\n <h2 id=\"brycks-modal-title\" style={titleStyle}>\r\n {title}\r\n </h2>\r\n )}\r\n {description && (\r\n <p id=\"brycks-modal-description\" style={descriptionStyle}>\r\n {description}\r\n </p>\r\n )}\r\n </div>\r\n {showCloseButton && (\r\n <button\r\n type=\"button\"\r\n className=\"brycks-modal-close\"\r\n style={closeButtonStyle}\r\n onClick={onClose}\r\n aria-label=\"Close modal\"\r\n onMouseEnter={(e) => {\r\n e.currentTarget.style.backgroundColor = 'var(--brycks-background-muted)'\r\n e.currentTarget.style.color = 'var(--brycks-foreground-default)'\r\n }}\r\n onMouseLeave={(e) => {\r\n e.currentTarget.style.backgroundColor = 'transparent'\r\n e.currentTarget.style.color = 'var(--brycks-foreground-muted)'\r\n }}\r\n >\r\n <CloseIcon />\r\n </button>\r\n )}\r\n </div>\r\n )}\r\n\r\n <div className=\"brycks-modal-content\" style={contentStyle}>\r\n {children}\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n\r\n return createPortal(modalContent, document.body)\r\n})\r\n\r\nModal.displayName = 'Modal'\r\n"],"names":["sizeWidths","CloseIcon","memo","jsx","Modal","forwardRef","isOpen","onClose","size","title","description","closeOnOverlayClick","closeOnEscape","showCloseButton","className","style","testId","children","props","ref","modalRef","useRef","previousActiveElement","wasOpen","useEffect","onCloseRef","modal","handleKeyDown","e","focusableElements","firstElement","lastElement","handleOverlayClick","useCallback","overlayStyle","useMemo","spacing","modalStyle","headerStyle","titleContainerStyle","titleStyle","fontSizes","descriptionStyle","closeButtonStyle","iconButtonSizes","componentGap","contentStyle","modalContent","jsxs","node","cx","createPortal"],"mappings":";;;;;;;;AAkDA,MAAMA,IAAwC;AAAA,EAC5C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR,GAGMC,IAAYC,EAAK,WAAqB;AAC1C,SACE,gBAAAC,EAAC,OAAA,EAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACtE,UAAA,gBAAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,GAAE;AAAA,MACF,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,IAAA;AAAA,EAAA,GAElB;AAEJ,CAAC,GAEYC,IAAQC,EAAuC,SAC1D;AAAA,EACE,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,qBAAAC,IAAsB;AAAA,EACtB,eAAAC,IAAgB;AAAA,EAChB,iBAAAC,IAAkB;AAAA,EAClB,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAAWC,EAAuB,IAAI,GACtCC,IAAwBD,EAA2B,IAAI,GACvDE,IAAUF,EAAO,EAAK;AAG5B,EAAAG,EAAU,MAAM;AAEd,IAAIlB,KAAU,CAACiB,EAAQ,WACrBD,EAAsB,UAAU,SAAS,eACzCC,EAAQ,UAAU,MAGX,CAACjB,KAAUi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BACC,MAAK;AAAA,kBACL,WAAU;AAAA,kBACV,OAAOwC;AAAA,kBACP,SAASpC;AAAA,kBACT,cAAW;AAAA,kBACX,cAAc,CAAC,MAAM;AACnB,sBAAE,cAAc,MAAM,kBAAkB,kCACxC,EAAE,cAAc,MAAM,QAAQ;AAAA,kBAChC;AAAA,kBACA,cAAc,CAAC,MAAM;AACnB,sBAAE,cAAc,MAAM,kBAAkB,eACxC,EAAE,cAAc,MAAM,QAAQ;AAAA,kBAChC;AAAA,kBAEA,4BAACN,GAAA,CAAA,CAAU;AAAA,gBAAA;AAAA,cAAA;AAAA,YACb,GAEJ;AAAA,8BAGD,OAAA,EAAI,WAAU,wBAAuB,OAAO6C,GAC1C,UAAA7B,EAAA,CACH;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAIN,SAAOkC,EAAaJ,GAAc,SAAS,IAAI;AACjD,CAAC;AAED3C,EAAM,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":["../../../../src/components/feedback/Modal/Modal.tsx"],"sourcesContent":["/**\r\n * Modal Component\r\n *\r\n * Accessible modal dialog with smooth Apple-inspired animations.\r\n * Supports focus trapping and keyboard navigation.\r\n */\r\n\r\nimport {\r\n forwardRef,\r\n useEffect,\r\n useRef,\r\n useCallback,\r\n useMemo,\r\n memo,\r\n type CSSProperties,\r\n type ReactNode,\r\n type HTMLAttributes,\r\n} from 'react'\r\nimport { createPortal } from 'react-dom'\r\nimport { cx } from '../../../utils/styles'\r\nimport { spacing, fontSizes } from '../../../design-system'\r\nimport { componentGap, iconButtonSizes } from '../../../design-system/primitives'\r\n\r\nexport type ModalSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full'\r\n\r\nexport interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\r\n /** Whether the modal is open */\r\n isOpen: boolean\r\n /** Callback when modal should close */\r\n onClose: () => void\r\n /** Modal size */\r\n size?: ModalSize\r\n /** Modal title */\r\n title?: ReactNode\r\n /** Modal description */\r\n description?: ReactNode\r\n /** Whether to close on overlay click */\r\n closeOnOverlayClick?: boolean\r\n /** Whether to close on escape key */\r\n closeOnEscape?: boolean\r\n /** Whether to show close button */\r\n showCloseButton?: boolean\r\n /** Custom class name */\r\n className?: string\r\n /** Test ID */\r\n testId?: string\r\n /** Modal content */\r\n children?: ReactNode\r\n}\r\n\r\nconst sizeWidths: Record<ModalSize, string> = {\r\n sm: '400px',\r\n md: '500px',\r\n lg: '640px',\r\n xl: '800px',\r\n '2xl': '1200px',\r\n full: 'calc(100vw - 48px)',\r\n}\r\n\r\n/** Close icon - memoized to prevent re-renders */\r\nconst CloseIcon = memo(function CloseIcon() {\r\n return (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\r\n <path\r\n d=\"M4 4L12 12M12 4L4 12\"\r\n stroke=\"currentColor\"\r\n strokeWidth=\"1.5\"\r\n strokeLinecap=\"round\"\r\n />\r\n </svg>\r\n )\r\n})\r\n\r\nexport const Modal = forwardRef<HTMLDivElement, ModalProps>(function Modal(\r\n {\r\n isOpen,\r\n onClose,\r\n size = 'md',\r\n title,\r\n description,\r\n closeOnOverlayClick = true,\r\n closeOnEscape = true,\r\n showCloseButton = true,\r\n className,\r\n style,\r\n testId,\r\n children,\r\n ...props\r\n },\r\n ref\r\n) {\r\n const modalRef = useRef<HTMLDivElement>(null)\r\n const previousActiveElement = useRef<HTMLElement | null>(null)\r\n const wasOpen = useRef(false)\r\n\r\n // Track previous open state to handle focus restoration before unmount\r\n useEffect(() => {\r\n // Modal just opened\r\n if (isOpen && !wasOpen.current) {\r\n previousActiveElement.current = document.activeElement as HTMLElement\r\n wasOpen.current = true\r\n }\r\n // Modal is about to close - restore focus BEFORE unmount\r\n else if (!isOpen && wasOpen.current) {\r\n // Blur any focused element inside modal to prevent aria-hidden warning\r\n if (document.activeElement instanceof HTMLElement) {\r\n document.activeElement.blur()\r\n }\r\n // Restore focus to previous element\r\n previousActiveElement.current?.focus()\r\n previousActiveElement.current = null\r\n wasOpen.current = false\r\n }\r\n }, [isOpen])\r\n\r\n // Store onClose in a ref to avoid re-running effects when it changes\r\n const onCloseRef = useRef(onClose)\r\n useEffect(() => {\r\n onCloseRef.current = onClose\r\n }, [onClose])\r\n\r\n // Focus modal when it opens (only once)\r\n useEffect(() => {\r\n if (!isOpen) return\r\n\r\n const modal = modalRef.current\r\n if (modal) {\r\n modal.focus()\r\n }\r\n }, [isOpen])\r\n\r\n // Keyboard handling and body scroll lock\r\n useEffect(() => {\r\n if (!isOpen) return\r\n\r\n const modal = modalRef.current\r\n\r\n const handleKeyDown = (e: KeyboardEvent) => {\r\n if (e.key === 'Escape' && closeOnEscape) {\r\n onCloseRef.current()\r\n return\r\n }\r\n\r\n if (e.key === 'Tab' && modal) {\r\n const focusableElements = modal.querySelectorAll<HTMLElement>(\r\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\r\n )\r\n const firstElement = focusableElements[0]\r\n const lastElement = focusableElements[focusableElements.length - 1]\r\n\r\n if (e.shiftKey && document.activeElement === firstElement) {\r\n e.preventDefault()\r\n lastElement?.focus()\r\n } else if (!e.shiftKey && document.activeElement === lastElement) {\r\n e.preventDefault()\r\n firstElement?.focus()\r\n }\r\n }\r\n }\r\n\r\n document.addEventListener('keydown', handleKeyDown)\r\n document.body.style.overflow = 'hidden'\r\n\r\n return () => {\r\n document.removeEventListener('keydown', handleKeyDown)\r\n document.body.style.overflow = ''\r\n }\r\n }, [isOpen, closeOnEscape])\r\n\r\n const handleOverlayClick = useCallback(\r\n (e: React.MouseEvent) => {\r\n if (e.target === e.currentTarget && closeOnOverlayClick) {\r\n onClose()\r\n }\r\n },\r\n [closeOnOverlayClick, onClose]\r\n )\r\n\r\n // Memoize styles to prevent object recreation on every render\r\n const overlayStyle = useMemo<CSSProperties>(() => ({\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 'var(--brycks-z-modal)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: spacing[6],\r\n backgroundColor: 'var(--brycks-background-overlay)',\r\n backdropFilter: 'blur(4px)',\r\n animation: 'brycks-fade-in var(--brycks-duration-normal) var(--brycks-ease-out)',\r\n }), [])\r\n\r\n const modalStyle = useMemo<CSSProperties>(() => ({\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: sizeWidths[size],\r\n maxHeight: size === 'full' ? 'calc(100vh - 48px)' : '85vh',\r\n backgroundColor: 'var(--brycks-background-elevated)',\r\n borderRadius: 'var(--brycks-radius-xl)',\r\n boxShadow: 'var(--brycks-shadow-2xl)',\r\n display: 'flex',\r\n flexDirection: 'column',\r\n overflow: 'hidden',\r\n animation: 'brycks-scale-in var(--brycks-duration-normal) var(--brycks-ease-spring)',\r\n outline: 'none',\r\n ...style,\r\n }), [size, style])\r\n\r\n if (!isOpen) return null\r\n\r\n const headerStyle: CSSProperties = {\r\n display: 'flex',\r\n alignItems: 'flex-start',\r\n justifyContent: 'space-between',\r\n padding: `${spacing[5]}px ${spacing[6]}px`,\r\n borderBottom: '1px solid var(--brycks-border-muted)',\r\n }\r\n\r\n const titleContainerStyle: CSSProperties = {\r\n display: 'flex',\r\n flexDirection: 'column',\r\n gap: spacing[1],\r\n }\r\n\r\n const titleStyle: CSSProperties = {\r\n fontSize: fontSizes.lg,\r\n fontWeight: 600,\r\n color: 'var(--brycks-foreground-default)',\r\n margin: 0,\r\n lineHeight: 1.3,\r\n }\r\n\r\n const descriptionStyle: CSSProperties = {\r\n fontSize: fontSizes.base,\r\n color: 'var(--brycks-foreground-muted)',\r\n margin: 0,\r\n }\r\n\r\n const closeButtonStyle: CSSProperties = {\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n width: iconButtonSizes.sm,\r\n height: iconButtonSizes.sm,\r\n borderRadius: 'var(--brycks-radius-md)',\r\n color: 'var(--brycks-foreground-muted)',\r\n transition: 'all var(--brycks-duration-fast) var(--brycks-ease-out)',\r\n marginLeft: componentGap.xl,\r\n flexShrink: 0,\r\n }\r\n\r\n const contentStyle: CSSProperties = {\r\n flex: 1,\r\n overflow: 'auto',\r\n padding: spacing[6],\r\n }\r\n\r\n const modalContent = (\r\n <div\r\n className=\"brycks-modal-overlay\"\r\n style={overlayStyle}\r\n onClick={handleOverlayClick}\r\n >\r\n <div\r\n ref={(node) => {\r\n (modalRef as React.MutableRefObject<HTMLDivElement | null>).current = node\r\n if (typeof ref === 'function') ref(node)\r\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node\r\n }}\r\n role=\"dialog\"\r\n aria-modal=\"true\"\r\n aria-labelledby={title ? 'brycks-modal-title' : undefined}\r\n aria-describedby={description ? 'brycks-modal-description' : undefined}\r\n className={cx('brycks-modal', `brycks-modal--${size}`, className)}\r\n style={modalStyle}\r\n tabIndex={-1}\r\n data-testid={testId}\r\n {...props}\r\n >\r\n {(title || showCloseButton) && (\r\n <div className=\"brycks-modal-header\" style={headerStyle}>\r\n <div style={titleContainerStyle}>\r\n {title && (\r\n <h2 id=\"brycks-modal-title\" style={titleStyle}>\r\n {title}\r\n </h2>\r\n )}\r\n {description && (\r\n <p id=\"brycks-modal-description\" style={descriptionStyle}>\r\n {description}\r\n </p>\r\n )}\r\n </div>\r\n {showCloseButton && (\r\n <button\r\n type=\"button\"\r\n className=\"brycks-modal-close\"\r\n style={closeButtonStyle}\r\n onClick={onClose}\r\n aria-label=\"Close modal\"\r\n onMouseEnter={(e) => {\r\n e.currentTarget.style.backgroundColor = 'var(--brycks-background-muted)'\r\n e.currentTarget.style.color = 'var(--brycks-foreground-default)'\r\n }}\r\n onMouseLeave={(e) => {\r\n e.currentTarget.style.backgroundColor = 'transparent'\r\n e.currentTarget.style.color = 'var(--brycks-foreground-muted)'\r\n }}\r\n >\r\n <CloseIcon />\r\n </button>\r\n )}\r\n </div>\r\n )}\r\n\r\n <div className=\"brycks-modal-content\" style={contentStyle}>\r\n {children}\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n\r\n return createPortal(modalContent, document.body)\r\n})\r\n\r\nModal.displayName = 'Modal'\r\n"],"names":["sizeWidths","CloseIcon","memo","jsx","Modal","forwardRef","isOpen","onClose","size","title","description","closeOnOverlayClick","closeOnEscape","showCloseButton","className","style","testId","children","props","ref","modalRef","useRef","previousActiveElement","wasOpen","useEffect","onCloseRef","modal","handleKeyDown","e","focusableElements","firstElement","lastElement","handleOverlayClick","useCallback","overlayStyle","useMemo","spacing","modalStyle","headerStyle","titleContainerStyle","titleStyle","fontSizes","descriptionStyle","closeButtonStyle","iconButtonSizes","componentGap","contentStyle","modalContent","jsxs","node","cx","createPortal"],"mappings":";;;;;;;;AAkDA,MAAMA,IAAwC;AAAA,EAC5C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,MAAM;AACR,GAGMC,IAAYC,EAAK,WAAqB;AAC1C,SACE,gBAAAC,EAAC,OAAA,EAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACtE,UAAA,gBAAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,GAAE;AAAA,MACF,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,IAAA;AAAA,EAAA,GAElB;AAEJ,CAAC,GAEYC,IAAQC,EAAuC,SAC1D;AAAA,EACE,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,qBAAAC,IAAsB;AAAA,EACtB,eAAAC,IAAgB;AAAA,EAChB,iBAAAC,IAAkB;AAAA,EAClB,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAAWC,EAAuB,IAAI,GACtCC,IAAwBD,EAA2B,IAAI,GACvDE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AP,EAAC,KAAA,EAAE,IAAG,4BAA2B,OAAOuC,GACrC,UAAAhC,EAAA,CACH;AAAA,cAAA,GAEJ;AAAA,cACCG,KACC,gBAAAV;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,MAAK;AAAA,kBACL,WAAU;AAAA,kBACV,OAAOwC;AAAA,kBACP,SAASpC;AAAA,kBACT,cAAW;AAAA,kBACX,cAAc,CAAC,MAAM;AACnB,sBAAE,cAAc,MAAM,kBAAkB,kCACxC,EAAE,cAAc,MAAM,QAAQ;AAAA,kBAChC;AAAA,kBACA,cAAc,CAAC,MAAM;AACnB,sBAAE,cAAc,MAAM,kBAAkB,eACxC,EAAE,cAAc,MAAM,QAAQ;AAAA,kBAChC;AAAA,kBAEA,4BAACN,GAAA,CAAA,CAAU;AAAA,gBAAA;AAAA,cAAA;AAAA,YACb,GAEJ;AAAA,8BAGD,OAAA,EAAI,WAAU,wBAAuB,OAAO6C,GAC1C,UAAA7B,EAAA,CACH;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAIN,SAAOkC,EAAaJ,GAAc,SAAS,IAAI;AACjD,CAAC;AAED3C,EAAM,cAAc;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),T=require("../../../utils/styles.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),T=require("../../../utils/styles.cjs"),n=require("../../../design-system/primitives/opacity.cjs"),p=require("../../../design-system/primitives/sizing.cjs"),h=require("../../../design-system/primitives/typography.cjs"),m=require("../../../design-system/primitives/focus.cjs"),v=require("../../../design-system/primitives/transitions.cjs");function D({size:o}){return e.jsx("svg",{width:o,height:o,viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M2.5 6L5 8.5L9.5 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function G({size:o}){return e.jsx("svg",{width:o,height:o,viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M2.5 6H9.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}const S=c.forwardRef(function({size:i="md",label:a,description:l,isInvalid:u,isIndeterminate:b,className:j,style:w,testId:C,disabled:s,checked:k,onChange:q,...L},M){const[x,f]=c.useState(!1),[H,g]=c.useState(!1),[R,d]=c.useState(!1),t=p.controlSizes[i],y=h.componentFontSize[i],r=k||b,$={display:"inline-flex",alignItems:"flex-start",gap:p.componentGap.lg,cursor:s?"not-allowed":"pointer",opacity:s?n.stateOpacity.disabled:1},I={position:"relative",width:t.box,height:t.box,borderRadius:"var(--brycks-radius-sm)",border:`1.5px solid ${u?"var(--brycks-error-default)":r?"var(--brycks-primary-default)":x?"var(--brycks-border-focus)":"var(--brycks-border-default)"}`,backgroundColor:r?"var(--brycks-primary-default)":H?"var(--brycks-background-subtle)":"var(--brycks-background-app)",transition:v.transition.quick,transform:R?`scale(${n.scale.controlPressed})`:`scale(${n.scale.normal})`,boxShadow:x?m.focusRing.default:m.focusRing.none,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},F={color:"var(--brycks-primary-foreground)",opacity:r?1:0,transform:r?`scale(${n.scale.normal})`:`scale(${n.scale.hidden})`,transition:v.transition.quick},P={position:"absolute",width:"100%",height:"100%",opacity:0,cursor:s?"not-allowed":"pointer",margin:0},z={display:"flex",flexDirection:"column",gap:p.componentGap.xs,paddingTop:(t.box-y)/2},B={fontSize:y,lineHeight:h.componentLineHeight.snug,color:"var(--brycks-foreground-default)",userSelect:"none"},O={fontSize:y-1,lineHeight:h.componentLineHeight.snug,color:"var(--brycks-foreground-muted)",userSelect:"none"};return e.jsxs("label",{className:T.cx("brycks-checkbox",`brycks-checkbox--${i}`,r&&"brycks-checkbox--checked",u&&"brycks-checkbox--invalid",s&&"brycks-checkbox--disabled",j),style:{...$,...w},"data-testid":C,onMouseEnter:()=>g(!0),onMouseLeave:()=>{g(!1),d(!1)},onMouseDown:()=>d(!0),onMouseUp:()=>d(!1),children:[e.jsxs("span",{style:I,children:[e.jsx("input",{ref:M,type:"checkbox",style:P,checked:k,disabled:s,"aria-invalid":u,onChange:q,onFocus:()=>f(!0),onBlur:()=>f(!1),...L}),e.jsx("span",{style:F,children:b?e.jsx(G,{size:t.icon}):e.jsx(D,{size:t.icon})})]}),(a||l)&&e.jsxs("span",{style:z,children:[a&&e.jsx("span",{style:B,children:a}),l&&e.jsx("span",{style:O,children:l})]})]})});S.displayName="Checkbox";exports.Checkbox=S;
|
|
2
2
|
//# sourceMappingURL=Checkbox.cjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsxs as p, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as N, useState as f } from "react";
|
|
3
3
|
import { cx as O } from "../../../utils/styles.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { stateOpacity as T, scale as s } from "../../../design-system/primitives/opacity.js";
|
|
5
|
+
import { componentGap as x, controlSizes as W } from "../../../design-system/primitives/sizing.js";
|
|
6
|
+
import { componentLineHeight as g, componentFontSize as E } from "../../../design-system/primitives/typography.js";
|
|
7
|
+
import { focusRing as v } from "../../../design-system/primitives/focus.js";
|
|
8
|
+
import { transition as S } from "../../../design-system/primitives/transitions.js";
|
|
9
9
|
function G({ size: o }) {
|
|
10
10
|
return /* @__PURE__ */ e("svg", { width: o, height: o, viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ e(
|
|
11
11
|
"path",
|
|
@@ -43,12 +43,12 @@ const A = N(function({
|
|
|
43
43
|
onChange: M,
|
|
44
44
|
...H
|
|
45
45
|
}, $) {
|
|
46
|
-
const [k, b] = f(!1), [I, m] = f(!1), [j, d] = f(!1), t =
|
|
46
|
+
const [k, b] = f(!1), [I, m] = f(!1), [j, d] = f(!1), t = W[c], u = E[c], n = h || y, F = {
|
|
47
47
|
display: "inline-flex",
|
|
48
48
|
alignItems: "flex-start",
|
|
49
49
|
gap: x.lg,
|
|
50
50
|
cursor: r ? "not-allowed" : "pointer",
|
|
51
|
-
opacity: r ?
|
|
51
|
+
opacity: r ? T.disabled : 1
|
|
52
52
|
}, B = {
|
|
53
53
|
position: "relative",
|
|
54
54
|
width: t.box,
|
|
@@ -56,9 +56,9 @@ const A = N(function({
|
|
|
56
56
|
borderRadius: "var(--brycks-radius-sm)",
|
|
57
57
|
border: `1.5px solid ${l ? "var(--brycks-error-default)" : n ? "var(--brycks-primary-default)" : k ? "var(--brycks-border-focus)" : "var(--brycks-border-default)"}`,
|
|
58
58
|
backgroundColor: n ? "var(--brycks-primary-default)" : I ? "var(--brycks-background-subtle)" : "var(--brycks-background-app)",
|
|
59
|
-
transition:
|
|
59
|
+
transition: S.quick,
|
|
60
60
|
transform: j ? `scale(${s.controlPressed})` : `scale(${s.normal})`,
|
|
61
|
-
boxShadow: k ?
|
|
61
|
+
boxShadow: k ? v.default : v.none,
|
|
62
62
|
display: "flex",
|
|
63
63
|
alignItems: "center",
|
|
64
64
|
justifyContent: "center",
|
|
@@ -67,7 +67,7 @@ const A = N(function({
|
|
|
67
67
|
color: "var(--brycks-primary-foreground)",
|
|
68
68
|
opacity: n ? 1 : 0,
|
|
69
69
|
transform: n ? `scale(${s.normal})` : `scale(${s.hidden})`,
|
|
70
|
-
transition:
|
|
70
|
+
transition: S.quick
|
|
71
71
|
}, R = {
|
|
72
72
|
position: "absolute",
|
|
73
73
|
width: "100%",
|
|
@@ -82,12 +82,12 @@ const A = N(function({
|
|
|
82
82
|
paddingTop: (t.box - u) / 2
|
|
83
83
|
}, z = {
|
|
84
84
|
fontSize: u,
|
|
85
|
-
lineHeight:
|
|
85
|
+
lineHeight: g.snug,
|
|
86
86
|
color: "var(--brycks-foreground-default)",
|
|
87
87
|
userSelect: "none"
|
|
88
88
|
}, D = {
|
|
89
89
|
fontSize: u - 1,
|
|
90
|
-
lineHeight:
|
|
90
|
+
lineHeight: g.snug,
|
|
91
91
|
color: "var(--brycks-foreground-muted)",
|
|
92
92
|
userSelect: "none"
|
|
93
93
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),y=require("react"),F=require("../../../utils/styles.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),y=require("react"),F=require("../../../utils/styles.cjs"),t=require("../../../design-system/primitives/sizing.cjs"),d=require("../../../design-system/primitives/typography.cjs"),f=require("../../../design-system/primitives/transitions.cjs"),u=require("../../../design-system/primitives/focus.cjs"),C=require("../../../design-system/primitives/opacity.cjs"),O={sm:{height:t.componentHeights.sm,fontSize:d.componentFontSize.sm,paddingX:t.componentPaddingX.sm,radius:"var(--brycks-radius-md)"},md:{height:t.componentHeights.md,fontSize:d.componentFontSize.md,paddingX:t.componentPaddingX.md,radius:"var(--brycks-radius-default)"},lg:{height:t.componentHeights.lg,fontSize:d.componentFontSize.lg,paddingX:t.componentPaddingX.lg,radius:"var(--brycks-radius-lg)"}},m=y.forwardRef(function({size:p="md",variant:l="outline",isInvalid:n,leftElement:i,rightElement:c,className:k,style:h,testId:S,disabled:o,onFocus:v,onBlur:x,...w},j){const[s,g]=y.useState(!1),r=O[p],R=()=>{const e={display:"flex",alignItems:"center",width:"100%",position:"relative",height:r.height,borderRadius:r.radius,transition:f.transition.default};switch(l){case"outline":Object.assign(e,{backgroundColor:"var(--brycks-background-app)",border:`1px solid ${n?"var(--brycks-error-default)":s?"var(--brycks-border-focus)":"var(--brycks-border-default)"}`,boxShadow:s?n?u.focusRing.error:u.focusRing.default:u.focusRing.none});break;case"filled":Object.assign(e,{backgroundColor:"var(--brycks-background-muted)",border:"1px solid transparent",borderColor:n?"var(--brycks-error-default)":s?"var(--brycks-border-focus)":"transparent"});break;case"flushed":Object.assign(e,{backgroundColor:"transparent",borderRadius:0,borderBottom:`2px solid ${n?"var(--brycks-error-default)":s?"var(--brycks-border-focus)":"var(--brycks-border-default)"}`});break}return o&&Object.assign(e,{opacity:C.stateOpacity.disabled,cursor:"not-allowed"}),e},X={width:"100%",height:r.height,fontFamily:"var(--brycks-font-sans)",fontSize:r.fontSize,color:"var(--brycks-foreground-default)",backgroundColor:"transparent",border:"none",outline:"none",borderRadius:r.radius,paddingLeft:i?t.componentGap.md:r.paddingX,paddingRight:c?t.componentGap.md:r.paddingX,cursor:o?"not-allowed":"text",transition:f.transition.default},z=e=>{g(!0),v?.(e)},q=e=>{g(!1),x?.(e)},b={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--brycks-foreground-muted)",flexShrink:0};return a.jsxs("div",{className:F.cx("brycks-input-wrapper",`brycks-input-wrapper--${l}`,`brycks-input-wrapper--${p}`,n&&"brycks-input-wrapper--invalid",o&&"brycks-input-wrapper--disabled",k),style:{...R(),...h},children:[i&&a.jsx("span",{className:"brycks-input-left-element",style:{...b,paddingLeft:r.paddingX},children:i}),a.jsx("input",{ref:j,className:"brycks-input",style:X,disabled:o,"aria-invalid":n,"data-testid":S,onFocus:z,onBlur:q,...w}),c&&a.jsx("span",{className:"brycks-input-right-element",style:{...b,paddingRight:r.paddingX},children:c})]})});m.displayName="Input";exports.Input=m;
|
|
2
2
|
//# sourceMappingURL=Input.cjs.map
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { jsxs as F, jsx as d } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as N, useState as O } from "react";
|
|
3
3
|
import { cx as $ } from "../../../utils/styles.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { componentPaddingX as p, componentHeights as u, componentGap as m } from "../../../design-system/primitives/sizing.js";
|
|
4
|
+
import { componentPaddingX as i, componentHeights as c, componentGap as m } from "../../../design-system/primitives/sizing.js";
|
|
5
|
+
import { componentFontSize as p } from "../../../design-system/primitives/typography.js";
|
|
7
6
|
import { transition as y } from "../../../design-system/primitives/transitions.js";
|
|
7
|
+
import { focusRing as u } from "../../../design-system/primitives/focus.js";
|
|
8
8
|
import { stateOpacity as B } from "../../../design-system/primitives/opacity.js";
|
|
9
9
|
const L = {
|
|
10
10
|
sm: {
|
|
11
|
-
height:
|
|
12
|
-
fontSize:
|
|
13
|
-
paddingX:
|
|
11
|
+
height: c.sm,
|
|
12
|
+
fontSize: p.sm,
|
|
13
|
+
paddingX: i.sm,
|
|
14
14
|
radius: "var(--brycks-radius-md)"
|
|
15
15
|
},
|
|
16
16
|
md: {
|
|
17
|
-
height:
|
|
18
|
-
fontSize:
|
|
19
|
-
paddingX:
|
|
17
|
+
height: c.md,
|
|
18
|
+
fontSize: p.md,
|
|
19
|
+
paddingX: i.md,
|
|
20
20
|
radius: "var(--brycks-radius-default)"
|
|
21
21
|
},
|
|
22
22
|
lg: {
|
|
23
|
-
height:
|
|
24
|
-
fontSize:
|
|
25
|
-
paddingX:
|
|
23
|
+
height: c.lg,
|
|
24
|
+
fontSize: p.lg,
|
|
25
|
+
paddingX: i.lg,
|
|
26
26
|
radius: "var(--brycks-radius-lg)"
|
|
27
27
|
}
|
|
28
28
|
}, G = N(function({
|
|
@@ -54,7 +54,7 @@ const L = {
|
|
|
54
54
|
Object.assign(e, {
|
|
55
55
|
backgroundColor: "var(--brycks-background-app)",
|
|
56
56
|
border: `1px solid ${t ? "var(--brycks-error-default)" : a ? "var(--brycks-border-focus)" : "var(--brycks-border-default)"}`,
|
|
57
|
-
boxShadow: a ? t ?
|
|
57
|
+
boxShadow: a ? t ? u.error : u.default : u.none
|
|
58
58
|
});
|
|
59
59
|
break;
|
|
60
60
|
case "filled":
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("react"),J=require("../../../utils/styles.cjs"),m=require("../../../design-system/tokens/typography.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("react"),J=require("../../../utils/styles.cjs"),m=require("../../../design-system/tokens/typography.cjs"),c=require("../../../design-system/tokens/motion.cjs"),l=require("../../../design-system/tokens/spacing.cjs"),z=require("../../../design-system/primitives/sizing.cjs"),Q={sm:{track:l.spacing[1],thumb:l.spacing[3.5],fontSize:m.fontSizes.sm},md:{track:z.componentGap.sm,thumb:l.spacing[4]+l.spacing[.5],fontSize:m.fontSizes.base},lg:{track:l.spacing[2],thumb:l.spacing[5]+l.spacing[.5],fontSize:m.fontSizes.md}},R=i.forwardRef(function({size:k="md",min:a=0,max:u=100,step:f=1,value:b,defaultValue:C=a,onChange:S,showValue:w=!1,formatValue:x=v=>String(v),label:p,disabled:d=!1,className:q,style:E,testId:M,...I},g){const[v,O]=i.useState(C),[y,h]=i.useState(!1),[A,D]=i.useState(!1),$=i.useRef(null),s=b??v,t=Q[k],j=(s-a)/(u-a)*100,r=i.useCallback(e=>{const n=Math.max(a,Math.min(u,e));b===void 0&&O(n),S?.(n)},[b,a,u,S]);i.useEffect(()=>{const e=$.current;if(!e)return;const n=V=>{const B=V.target;r(parseFloat(B.value))};return e.addEventListener("input",n),()=>e.removeEventListener("input",n)},[r]);const L=i.useCallback(e=>{const n=e.shiftKey?f*10:f;switch(e.key){case"ArrowRight":case"ArrowUp":e.preventDefault(),r(s+n);break;case"ArrowLeft":case"ArrowDown":e.preventDefault(),r(s-n);break;case"Home":e.preventDefault(),r(a);break;case"End":e.preventDefault(),r(u);break;case"PageUp":e.preventDefault(),r(s+n*10);break;case"PageDown":e.preventDefault(),r(s-n*10);break}},[s,f,a,u,r]),H={display:"flex",flexDirection:"column",gap:l.spacing[2],opacity:d?.5:1,...E},K={display:"flex",alignItems:"center",justifyContent:"space-between",gap:z.componentGap.xl},N={fontSize:t.fontSize,fontWeight:500,color:"var(--brycks-foreground-default)"},P={fontSize:t.fontSize,fontWeight:500,color:"var(--brycks-foreground-muted)",fontVariantNumeric:"tabular-nums"},T={position:"relative",display:"flex",alignItems:"center",height:t.thumb,cursor:d?"not-allowed":"pointer"},U={position:"absolute",width:"100%",height:t.track,borderRadius:t.track/2,backgroundColor:"var(--brycks-background-muted)"},G={position:"absolute",left:0,height:t.track,width:`${j}%`,borderRadius:t.track/2,backgroundColor:d?"var(--brycks-foreground-muted)":"var(--brycks-primary-default)",transition:y?"none":`width ${c.durations.fast}ms ${c.easings.easeOut}`},W={position:"absolute",left:`calc(${j}% - ${t.thumb/2}px)`,width:t.thumb,height:t.thumb,borderRadius:"50%",backgroundColor:"white",border:`2px solid ${d?"var(--brycks-foreground-muted)":"var(--brycks-primary-default)"}`,boxShadow:y||A?"var(--brycks-shadow-md)":"var(--brycks-shadow-sm)",transform:y?"scale(1.1)":"scale(1)",transition:y?`transform ${c.durations.fast}ms ${c.easings.easeOut}, box-shadow ${c.durations.fast}ms ${c.easings.easeOut}`:`all ${c.durations.fast}ms ${c.easings.easeOut}`,pointerEvents:"none"},F={position:"absolute",width:"100%",height:t.thumb,margin:0,padding:0,opacity:0,cursor:d?"not-allowed":"pointer"};return o.jsxs("div",{className:J.cx("brycks-slider",`brycks-slider--${k}`,q),style:H,children:[(p||w)&&o.jsxs("div",{style:K,children:[p&&o.jsx("span",{style:N,children:p}),w&&o.jsx("span",{style:P,children:x(s)})]}),o.jsxs("div",{style:T,onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1),children:[o.jsx("div",{style:U}),o.jsx("div",{style:G}),o.jsx("div",{style:W}),o.jsx("input",{ref:e=>{$.current=e,typeof g=="function"?g(e):g&&(g.current=e)},type:"range",role:"slider","aria-valuemin":a,"aria-valuemax":u,"aria-valuenow":s,"aria-valuetext":x(s),"aria-label":p,min:a,max:u,step:f,value:s,disabled:d,style:F,onKeyDown:L,onMouseDown:()=>h(!0),onMouseUp:()=>h(!1),onTouchStart:()=>h(!0),onTouchEnd:()=>h(!1),"data-testid":M,...I})]})]})});R.displayName="Slider";exports.Slider=R;
|
|
2
2
|
//# sourceMappingURL=Slider.cjs.map
|
|
@@ -2,9 +2,9 @@ import { jsxs as v, jsx as c } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef as X, useState as k, useRef as Y, useCallback as E, useEffect as Z } from "react";
|
|
3
3
|
import { cx as _ } from "../../../utils/styles.js";
|
|
4
4
|
import { fontSizes as w } from "../../../design-system/tokens/typography.js";
|
|
5
|
+
import { durations as m, easings as y } from "../../../design-system/tokens/motion.js";
|
|
5
6
|
import { spacing as s } from "../../../design-system/tokens/spacing.js";
|
|
6
7
|
import { componentGap as I } from "../../../design-system/primitives/sizing.js";
|
|
7
|
-
import { durations as m, easings as y } from "../../../design-system/tokens/motion.js";
|
|
8
8
|
const ee = {
|
|
9
9
|
sm: { track: s[1], thumb: s[3.5], fontSize: w.sm },
|
|
10
10
|
md: { track: I.sm, thumb: s[4] + s[0.5], fontSize: w.base },
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),y=require("react"),_=require("../../../utils/styles.cjs"),k=require("../../../design-system/primitives/sizing.cjs"),n=y.forwardRef(function({size:r="md",label:e,description:h,className:l,style:b,testId:w,disabled:a,checked:c,onChange:d,...u},o){const s=k.switchSizes[r],i=(s.height-s.thumb)/2,m=s.width-s.thumb-i*2;return t.jsxs("label",{className:_.cx("brycks-switch",`brycks-switch--${r}`,c&&"brycks-switch--checked",a&&"brycks-switch--disabled",l),style:b,"data-testid":w,children:[t.jsxs("span",{className:"brycks-switch__track",style:{width:s.width,height:s.height,borderRadius:s.height/2},children:[t.jsx("input",{ref:o,type:"checkbox",role:"switch",className:"brycks-switch__input",checked:c,disabled:a,"aria-checked":c,onChange:d,...u}),t.jsx("span",{className:"brycks-switch__thumb",style:{top:i,left:c?i+m:i,width:s.thumb,height:s.thumb,borderRadius:s.thumb/2}})]}),(e||h)&&t.jsxs("span",{className:"brycks-switch__label",children:[e&&t.jsx("span",{className:"brycks-switch__label-text",children:e}),h&&t.jsx("span",{className:"brycks-switch__description",children:h})]})]})});n.displayName="Switch";exports.Switch=n;
|
|
2
2
|
//# sourceMappingURL=Switch.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.cjs","sources":["../../../../src/components/form/Switch/Switch.tsx"],"sourcesContent":["/**\r\n * Switch Component\r\n *\r\n * Apple-inspired toggle switch with smooth spring animation.\r\n * Clean, tactile design with satisfying micro-interactions.\r\n *\r\n * @module components/form/Switch\r\n */\r\n\r\nimport {\r\n forwardRef,\r\n
|
|
1
|
+
{"version":3,"file":"Switch.cjs","sources":["../../../../src/components/form/Switch/Switch.tsx"],"sourcesContent":["/**\r\n * Switch Component\r\n *\r\n * Apple-inspired toggle switch with smooth spring animation.\r\n * Clean, tactile design with satisfying micro-interactions.\r\n *\r\n * All color styles are handled via CSS classes for easy customization.\r\n *\r\n * @module components/form/Switch\r\n */\r\n\r\nimport {\r\n forwardRef,\r\n type InputHTMLAttributes,\r\n type ReactNode,\r\n} from 'react'\r\nimport { switchSizes } from '../../../design-system'\r\nimport { cx } from '../../../utils/styles'\r\n\r\nexport type SwitchSize = 'sm' | 'md' | 'lg'\r\n\r\nexport interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'> {\r\n /** Switch size */\r\n size?: SwitchSize\r\n /** Label text */\r\n label?: ReactNode\r\n /** Description below label */\r\n description?: ReactNode\r\n /** Custom class name */\r\n className?: string\r\n /** Test ID */\r\n testId?: string\r\n}\r\n\r\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\r\n {\r\n size = 'md',\r\n label,\r\n description,\r\n className,\r\n style,\r\n testId,\r\n disabled,\r\n checked,\r\n onChange,\r\n ...props\r\n },\r\n ref\r\n) {\r\n const config = switchSizes[size]\r\n const padding = (config.height - config.thumb) / 2\r\n const travel = config.width - config.thumb - padding * 2\r\n\r\n return (\r\n <label\r\n className={cx(\r\n 'brycks-switch',\r\n `brycks-switch--${size}`,\r\n checked && 'brycks-switch--checked',\r\n disabled && 'brycks-switch--disabled',\r\n className\r\n )}\r\n style={style}\r\n data-testid={testId}\r\n >\r\n <span\r\n className=\"brycks-switch__track\"\r\n style={{\r\n width: config.width,\r\n height: config.height,\r\n borderRadius: config.height / 2,\r\n }}\r\n >\r\n <input\r\n ref={ref}\r\n type=\"checkbox\"\r\n role=\"switch\"\r\n className=\"brycks-switch__input\"\r\n checked={checked}\r\n disabled={disabled}\r\n aria-checked={checked}\r\n onChange={onChange}\r\n {...props}\r\n />\r\n <span\r\n className=\"brycks-switch__thumb\"\r\n style={{\r\n top: padding,\r\n left: checked ? padding + travel : padding,\r\n width: config.thumb,\r\n height: config.thumb,\r\n borderRadius: config.thumb / 2,\r\n }}\r\n />\r\n </span>\r\n\r\n {(label || description) && (\r\n <span className=\"brycks-switch__label\">\r\n {label && <span className=\"brycks-switch__label-text\">{label}</span>}\r\n {description && <span className=\"brycks-switch__description\">{description}</span>}\r\n </span>\r\n )}\r\n </label>\r\n )\r\n})\r\n\r\nSwitch.displayName = 'Switch'\r\n"],"names":["Switch","forwardRef","size","label","description","className","style","testId","disabled","checked","onChange","props","ref","config","switchSizes","padding","travel","jsxs","cx","jsx"],"mappings":"yOAkCaA,EAASC,EAAAA,WAA0C,SAC9D,CACE,KAAAC,EAAO,KACP,MAAAC,EACA,YAAAC,EACA,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,SAAAC,EACA,QAAAC,EACA,SAAAC,EACA,GAAGC,CACL,EACAC,EACA,CACA,MAAMC,EAASC,EAAAA,YAAYZ,CAAI,EACzBa,GAAWF,EAAO,OAASA,EAAO,OAAS,EAC3CG,EAASH,EAAO,MAAQA,EAAO,MAAQE,EAAU,EAEvD,OACEE,EAAAA,KAAC,QAAA,CACC,UAAWC,EAAAA,GACT,gBACA,kBAAkBhB,CAAI,GACtBO,GAAW,yBACXD,GAAY,0BACZH,CAAA,EAEF,MAAAC,EACA,cAAaC,EAEb,SAAA,CAAAU,EAAAA,KAAC,OAAA,CACC,UAAU,uBACV,MAAO,CACL,MAAOJ,EAAO,MACd,OAAQA,EAAO,OACf,aAAcA,EAAO,OAAS,CAAA,EAGhC,SAAA,CAAAM,EAAAA,IAAC,QAAA,CACC,IAAAP,EACA,KAAK,WACL,KAAK,SACL,UAAU,uBACV,QAAAH,EACA,SAAAD,EACA,eAAcC,EACd,SAAAC,EACC,GAAGC,CAAA,CAAA,EAENQ,EAAAA,IAAC,OAAA,CACC,UAAU,uBACV,MAAO,CACL,IAAKJ,EACL,KAAMN,EAAUM,EAAUC,EAASD,EACnC,MAAOF,EAAO,MACd,OAAQA,EAAO,MACf,aAAcA,EAAO,MAAQ,CAAA,CAC/B,CAAA,CACF,CAAA,CAAA,GAGAV,GAASC,IACTa,EAAAA,KAAC,OAAA,CAAK,UAAU,uBACb,SAAA,CAAAd,GAASgB,EAAAA,IAAC,OAAA,CAAK,UAAU,4BAA6B,SAAAhB,EAAM,EAC5DC,GAAee,EAAAA,IAAC,OAAA,CAAK,UAAU,6BAA8B,SAAAf,CAAA,CAAY,CAAA,CAAA,CAC5E,CAAA,CAAA,CAAA,CAIR,CAAC,EAEDJ,EAAO,YAAc"}
|
|
@@ -1,118 +1,83 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cx as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
...k
|
|
20
|
-
}, v) {
|
|
21
|
-
const [F, h] = m(!1), [d, l] = m(!1), t = N[n], c = G[n], r = (t.height - t.thumb) / 2, R = t.width - t.thumb - r * 2, $ = {
|
|
22
|
-
display: "inline-flex",
|
|
23
|
-
alignItems: "flex-start",
|
|
24
|
-
gap: y.xl,
|
|
25
|
-
cursor: e ? "not-allowed" : "pointer",
|
|
26
|
-
opacity: e ? P.disabled : 1
|
|
27
|
-
}, C = {
|
|
28
|
-
position: "relative",
|
|
29
|
-
width: t.width,
|
|
30
|
-
height: t.height,
|
|
31
|
-
borderRadius: t.height / 2,
|
|
32
|
-
backgroundColor: o ? "var(--brycks-primary-default)" : "var(--brycks-background-muted)",
|
|
33
|
-
border: `1px solid ${o ? "var(--brycks-primary-default)" : "var(--brycks-border-default)"}`,
|
|
34
|
-
transition: b.spring,
|
|
35
|
-
boxShadow: F ? B.default : "inset 0 1px 2px rgba(0,0,0,0.05)",
|
|
36
|
-
flexShrink: 0
|
|
37
|
-
}, H = {
|
|
38
|
-
position: "absolute",
|
|
39
|
-
top: r,
|
|
40
|
-
left: o ? r + R : r,
|
|
41
|
-
width: d ? t.thumb + 4 : t.thumb,
|
|
42
|
-
height: t.thumb,
|
|
43
|
-
borderRadius: t.thumb / 2,
|
|
44
|
-
backgroundColor: "var(--brycks-background-elevated)",
|
|
45
|
-
boxShadow: "var(--brycks-shadow-sm)",
|
|
46
|
-
transition: b.spring,
|
|
47
|
-
transform: d ? `scale(${f.pressedStrong})` : `scale(${f.normal})`
|
|
48
|
-
}, I = {
|
|
49
|
-
position: "absolute",
|
|
50
|
-
width: "100%",
|
|
51
|
-
height: "100%",
|
|
52
|
-
opacity: 0,
|
|
53
|
-
cursor: e ? "not-allowed" : "pointer",
|
|
54
|
-
margin: 0
|
|
55
|
-
}, M = {
|
|
56
|
-
display: "flex",
|
|
57
|
-
flexDirection: "column",
|
|
58
|
-
gap: y.xs,
|
|
59
|
-
paddingTop: (t.height - c * u.snug) / 2
|
|
60
|
-
}, j = {
|
|
61
|
-
fontSize: c,
|
|
62
|
-
lineHeight: u.snug,
|
|
63
|
-
color: "var(--brycks-foreground-default)",
|
|
64
|
-
userSelect: "none"
|
|
65
|
-
}, z = {
|
|
66
|
-
fontSize: c - 1,
|
|
67
|
-
lineHeight: u.snug,
|
|
68
|
-
color: "var(--brycks-foreground-muted)",
|
|
69
|
-
userSelect: "none"
|
|
70
|
-
};
|
|
71
|
-
return /* @__PURE__ */ p(
|
|
1
|
+
import { jsxs as a, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as y } from "react";
|
|
3
|
+
import { cx as u } from "../../../utils/styles.js";
|
|
4
|
+
import { switchSizes as _ } from "../../../design-system/primitives/sizing.js";
|
|
5
|
+
const k = y(function({
|
|
6
|
+
size: e = "md",
|
|
7
|
+
label: h,
|
|
8
|
+
description: r,
|
|
9
|
+
className: b,
|
|
10
|
+
style: l,
|
|
11
|
+
testId: n,
|
|
12
|
+
disabled: m,
|
|
13
|
+
checked: s,
|
|
14
|
+
onChange: o,
|
|
15
|
+
...w
|
|
16
|
+
}, d) {
|
|
17
|
+
const t = _[e], c = (t.height - t.thumb) / 2, p = t.width - t.thumb - c * 2;
|
|
18
|
+
return /* @__PURE__ */ a(
|
|
72
19
|
"label",
|
|
73
20
|
{
|
|
74
|
-
className:
|
|
21
|
+
className: u(
|
|
75
22
|
"brycks-switch",
|
|
76
|
-
`brycks-switch--${
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
23
|
+
`brycks-switch--${e}`,
|
|
24
|
+
s && "brycks-switch--checked",
|
|
25
|
+
m && "brycks-switch--disabled",
|
|
26
|
+
b
|
|
80
27
|
),
|
|
81
|
-
style:
|
|
82
|
-
"data-testid":
|
|
83
|
-
onMouseDown: () => l(!0),
|
|
84
|
-
onMouseUp: () => l(!1),
|
|
85
|
-
onMouseLeave: () => l(!1),
|
|
28
|
+
style: l,
|
|
29
|
+
"data-testid": n,
|
|
86
30
|
children: [
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
31
|
+
/* @__PURE__ */ a(
|
|
32
|
+
"span",
|
|
33
|
+
{
|
|
34
|
+
className: "brycks-switch__track",
|
|
35
|
+
style: {
|
|
36
|
+
width: t.width,
|
|
37
|
+
height: t.height,
|
|
38
|
+
borderRadius: t.height / 2
|
|
39
|
+
},
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ i(
|
|
42
|
+
"input",
|
|
43
|
+
{
|
|
44
|
+
ref: d,
|
|
45
|
+
type: "checkbox",
|
|
46
|
+
role: "switch",
|
|
47
|
+
className: "brycks-switch__input",
|
|
48
|
+
checked: s,
|
|
49
|
+
disabled: m,
|
|
50
|
+
"aria-checked": s,
|
|
51
|
+
onChange: o,
|
|
52
|
+
...w
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ i(
|
|
56
|
+
"span",
|
|
57
|
+
{
|
|
58
|
+
className: "brycks-switch__thumb",
|
|
59
|
+
style: {
|
|
60
|
+
top: c,
|
|
61
|
+
left: s ? c + p : c,
|
|
62
|
+
width: t.thumb,
|
|
63
|
+
height: t.thumb,
|
|
64
|
+
borderRadius: t.thumb / 2
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
(h || r) && /* @__PURE__ */ a("span", { className: "brycks-switch__label", children: [
|
|
72
|
+
h && /* @__PURE__ */ i("span", { className: "brycks-switch__label-text", children: h }),
|
|
73
|
+
r && /* @__PURE__ */ i("span", { className: "brycks-switch__description", children: r })
|
|
109
74
|
] })
|
|
110
75
|
]
|
|
111
76
|
}
|
|
112
77
|
);
|
|
113
78
|
});
|
|
114
|
-
|
|
79
|
+
k.displayName = "Switch";
|
|
115
80
|
export {
|
|
116
|
-
|
|
81
|
+
k as Switch
|
|
117
82
|
};
|
|
118
83
|
//# sourceMappingURL=Switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sources":["../../../../src/components/form/Switch/Switch.tsx"],"sourcesContent":["/**\r\n * Switch Component\r\n *\r\n * Apple-inspired toggle switch with smooth spring animation.\r\n * Clean, tactile design with satisfying micro-interactions.\r\n *\r\n * @module components/form/Switch\r\n */\r\n\r\nimport {\r\n forwardRef,\r\n
|
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../../../../src/components/form/Switch/Switch.tsx"],"sourcesContent":["/**\r\n * Switch Component\r\n *\r\n * Apple-inspired toggle switch with smooth spring animation.\r\n * Clean, tactile design with satisfying micro-interactions.\r\n *\r\n * All color styles are handled via CSS classes for easy customization.\r\n *\r\n * @module components/form/Switch\r\n */\r\n\r\nimport {\r\n forwardRef,\r\n type InputHTMLAttributes,\r\n type ReactNode,\r\n} from 'react'\r\nimport { switchSizes } from '../../../design-system'\r\nimport { cx } from '../../../utils/styles'\r\n\r\nexport type SwitchSize = 'sm' | 'md' | 'lg'\r\n\r\nexport interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'> {\r\n /** Switch size */\r\n size?: SwitchSize\r\n /** Label text */\r\n label?: ReactNode\r\n /** Description below label */\r\n description?: ReactNode\r\n /** Custom class name */\r\n className?: string\r\n /** Test ID */\r\n testId?: string\r\n}\r\n\r\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\r\n {\r\n size = 'md',\r\n label,\r\n description,\r\n className,\r\n style,\r\n testId,\r\n disabled,\r\n checked,\r\n onChange,\r\n ...props\r\n },\r\n ref\r\n) {\r\n const config = switchSizes[size]\r\n const padding = (config.height - config.thumb) / 2\r\n const travel = config.width - config.thumb - padding * 2\r\n\r\n return (\r\n <label\r\n className={cx(\r\n 'brycks-switch',\r\n `brycks-switch--${size}`,\r\n checked && 'brycks-switch--checked',\r\n disabled && 'brycks-switch--disabled',\r\n className\r\n )}\r\n style={style}\r\n data-testid={testId}\r\n >\r\n <span\r\n className=\"brycks-switch__track\"\r\n style={{\r\n width: config.width,\r\n height: config.height,\r\n borderRadius: config.height / 2,\r\n }}\r\n >\r\n <input\r\n ref={ref}\r\n type=\"checkbox\"\r\n role=\"switch\"\r\n className=\"brycks-switch__input\"\r\n checked={checked}\r\n disabled={disabled}\r\n aria-checked={checked}\r\n onChange={onChange}\r\n {...props}\r\n />\r\n <span\r\n className=\"brycks-switch__thumb\"\r\n style={{\r\n top: padding,\r\n left: checked ? padding + travel : padding,\r\n width: config.thumb,\r\n height: config.thumb,\r\n borderRadius: config.thumb / 2,\r\n }}\r\n />\r\n </span>\r\n\r\n {(label || description) && (\r\n <span className=\"brycks-switch__label\">\r\n {label && <span className=\"brycks-switch__label-text\">{label}</span>}\r\n {description && <span className=\"brycks-switch__description\">{description}</span>}\r\n </span>\r\n )}\r\n </label>\r\n )\r\n})\r\n\r\nSwitch.displayName = 'Switch'\r\n"],"names":["Switch","forwardRef","size","label","description","className","style","testId","disabled","checked","onChange","props","ref","config","switchSizes","padding","travel","jsxs","cx","jsx"],"mappings":";;;;AAkCO,MAAMA,IAASC,EAA0C,SAC9D;AAAA,EACE,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAASC,EAAYZ,CAAI,GACzBa,KAAWF,EAAO,SAASA,EAAO,SAAS,GAC3CG,IAASH,EAAO,QAAQA,EAAO,QAAQE,IAAU;AAEvD,SACE,gBAAAE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACA,k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ict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("react"),i=require("../../../utils/styles.cjs"),f=o.forwardRef(function({variant:r="elevated",padding:e="md",interactive:a=!1,selected:d=!1,className:c,style:s,children:y,testId:b,..._},k){return t.jsx("div",{ref:k,className:i.cx("brycks-card",`brycks-card--${r}`,`brycks-card--padding-${e}`,a&&"brycks-card--interactive",d&&"brycks-card--selected",c),style:s,"data-testid":b,..._,children:y})});f.displayName="Card";const l=o.forwardRef(function({divider:r=!1,className:e,style:a,children:d,...c},s){return t.jsx("div",{ref:s,className:i.cx("brycks-card__header",r&&"brycks-card__header--divider",e),style:a,...c,children:d})});l.displayName="CardHeader";const C=o.forwardRef(function({className:r,style:e,children:a,...d},c){return t.jsx("div",{ref:c,className:i.cx("brycks-card__body",r),style:e,...d,children:a})});C.displayName="CardBody";const u=o.forwardRef(function({divider:r=!1,align:e="right",className:a,style:d,children:c,...s},y){return t.jsx("div",{ref:y,className:i.cx("brycks-card__footer",r&&"brycks-card__footer--divider",`brycks-card__footer--${e}`,a),style:d,...s,children:c})});u.displayName="CardFooter";exports.Card=f;exports.CardBody=C;exports.CardFooter=u;exports.CardHeader=l;
|
|
2
2
|
//# sourceMappingURL=Card.cjs.map
|