asterui 0.12.48 → 0.12.50
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/Alert.js +18 -18
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Anchor.js +53 -53
- package/dist/components/Anchor.js.map +1 -1
- package/dist/components/Autocomplete.js +115 -114
- package/dist/components/Autocomplete.js.map +1 -1
- package/dist/components/Avatar.js +33 -32
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Badge.js +99 -99
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/Breadcrumb.js +12 -11
- package/dist/components/Breadcrumb.js.map +1 -1
- package/dist/components/Browser.js +10 -10
- package/dist/components/Browser.js.map +1 -1
- package/dist/components/Button.js +80 -79
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.d.ts +2 -0
- package/dist/components/Card.js +111 -110
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Carousel.js +59 -59
- package/dist/components/Carousel.js.map +1 -1
- package/dist/components/Cascader.js +175 -174
- package/dist/components/Cascader.js.map +1 -1
- package/dist/components/Chat.js +27 -27
- package/dist/components/Chat.js.map +1 -1
- package/dist/components/Checkbox.js +98 -97
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Code.js +11 -11
- package/dist/components/Code.js.map +1 -1
- package/dist/components/Collapse.js +46 -46
- package/dist/components/Collapse.js.map +1 -1
- package/dist/components/ColorPicker.d.ts +1 -1
- package/dist/components/ColorPicker.js +93 -91
- package/dist/components/ColorPicker.js.map +1 -1
- package/dist/components/Command.d.ts +65 -0
- package/dist/components/Command.js +422 -0
- package/dist/components/Command.js.map +1 -0
- package/dist/components/ConfigProvider.d.ts +1 -1
- package/dist/components/ConfigProvider.js +9 -9
- package/dist/components/ConfigProvider.js.map +1 -1
- package/dist/components/ContextMenu.js +33 -33
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton.js +74 -73
- package/dist/components/CopyButton.js.map +1 -1
- package/dist/components/Countdown.js +60 -59
- package/dist/components/Countdown.js.map +1 -1
- package/dist/components/DatePicker.d.ts +1 -1
- package/dist/components/DatePicker.js +54 -53
- package/dist/components/DatePicker.js.map +1 -1
- package/dist/components/Diff.js +10 -10
- package/dist/components/Diff.js.map +1 -1
- package/dist/components/Divider.js +21 -20
- package/dist/components/Divider.js.map +1 -1
- package/dist/components/Dock.js +28 -27
- package/dist/components/Dock.js.map +1 -1
- package/dist/components/Drawer.js +43 -43
- package/dist/components/Drawer.js.map +1 -1
- package/dist/components/Dropdown.js +127 -127
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/Empty.js +16 -15
- package/dist/components/Empty.js.map +1 -1
- package/dist/components/Fieldset.js +11 -10
- package/dist/components/Fieldset.js.map +1 -1
- package/dist/components/FileInput.js +30 -29
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Filter.d.ts +1 -1
- package/dist/components/Filter.js +32 -30
- package/dist/components/Filter.js.map +1 -1
- package/dist/components/FloatButton.js +83 -83
- package/dist/components/FloatButton.js.map +1 -1
- package/dist/components/Footer.js +14 -13
- package/dist/components/Footer.js.map +1 -1
- package/dist/components/Form.js +133 -132
- package/dist/components/Form.js.map +1 -1
- package/dist/components/Hero.js +12 -11
- package/dist/components/Hero.js.map +1 -1
- package/dist/components/HoverGallery.js +7 -7
- package/dist/components/HoverGallery.js.map +1 -1
- package/dist/components/Image.js +40 -40
- package/dist/components/Image.js.map +1 -1
- package/dist/components/Input.js +171 -169
- package/dist/components/Input.js.map +1 -1
- package/dist/components/InputNumber.js +84 -83
- package/dist/components/InputNumber.js.map +1 -1
- package/dist/components/Join.js +11 -10
- package/dist/components/Join.js.map +1 -1
- package/dist/components/Kbd.js +15 -15
- package/dist/components/Kbd.js.map +1 -1
- package/dist/components/Layout.js +66 -66
- package/dist/components/Layout.js.map +1 -1
- package/dist/components/List.d.ts +1 -1
- package/dist/components/List.js +75 -72
- package/dist/components/List.js.map +1 -1
- package/dist/components/Loading.d.ts +1 -1
- package/dist/components/Loading.js +31 -29
- package/dist/components/Loading.js.map +1 -1
- package/dist/components/Mask.js +31 -31
- package/dist/components/Mask.js.map +1 -1
- package/dist/components/Mention.js +61 -61
- package/dist/components/Mention.js.map +1 -1
- package/dist/components/Menu.js +84 -84
- package/dist/components/Menu.js.map +1 -1
- package/dist/components/Message.js +30 -29
- package/dist/components/Message.js.map +1 -1
- package/dist/components/Modal.js +117 -116
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/MonthCalendar.d.ts +31 -0
- package/dist/components/MonthCalendar.js +205 -0
- package/dist/components/MonthCalendar.js.map +1 -0
- package/dist/components/Navbar.js +25 -25
- package/dist/components/Navbar.js.map +1 -1
- package/dist/components/Notification.js +56 -55
- package/dist/components/Notification.js.map +1 -1
- package/dist/components/OTPInput.js +69 -68
- package/dist/components/OTPInput.js.map +1 -1
- package/dist/components/Pagination.d.ts +1 -1
- package/dist/components/Pagination.js +60 -58
- package/dist/components/Pagination.js.map +1 -1
- package/dist/components/Phone.js +10 -10
- package/dist/components/Phone.js.map +1 -1
- package/dist/components/Popconfirm.js +60 -60
- package/dist/components/Popconfirm.js.map +1 -1
- package/dist/components/Progress.js +17 -17
- package/dist/components/Progress.js.map +1 -1
- package/dist/components/QRCode.js +23 -23
- package/dist/components/QRCode.js.map +1 -1
- package/dist/components/RadialProgress.js +17 -17
- package/dist/components/RadialProgress.js.map +1 -1
- package/dist/components/Radio.js +41 -40
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Range.d.ts +1 -1
- package/dist/components/Range.js +39 -37
- package/dist/components/Range.js.map +1 -1
- package/dist/components/Rating.js +79 -78
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/ResponsiveDrawer.js +27 -27
- package/dist/components/ResponsiveDrawer.js.map +1 -1
- package/dist/components/RichTextEditor.d.ts +32 -0
- package/dist/components/RichTextEditor.js +335 -0
- package/dist/components/RichTextEditor.js.map +1 -0
- package/dist/components/Segmented.d.ts +1 -1
- package/dist/components/Segmented.js +48 -46
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +55 -54
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Skeleton.js +9 -9
- package/dist/components/Skeleton.js.map +1 -1
- package/dist/components/Splitter.js +93 -93
- package/dist/components/Splitter.js.map +1 -1
- package/dist/components/Stat.js +17 -16
- package/dist/components/Stat.js.map +1 -1
- package/dist/components/Status.js +29 -29
- package/dist/components/Status.js.map +1 -1
- package/dist/components/Steps.js +61 -61
- package/dist/components/Steps.js.map +1 -1
- package/dist/components/Table.js +256 -256
- package/dist/components/Table.js.map +1 -1
- package/dist/components/Tabs.js +65 -65
- package/dist/components/Tabs.js.map +1 -1
- package/dist/components/Tag.js +147 -147
- package/dist/components/Tag.js.map +1 -1
- package/dist/components/TextRotate.js +6 -6
- package/dist/components/TextRotate.js.map +1 -1
- package/dist/components/Textarea.js +35 -34
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/ThemeController.d.ts +1 -1
- package/dist/components/ThemeController.js +71 -68
- package/dist/components/ThemeController.js.map +1 -1
- package/dist/components/TimePicker.d.ts +1 -1
- package/dist/components/TimePicker.js +133 -129
- package/dist/components/TimePicker.js.map +1 -1
- package/dist/components/Timeline.js +79 -79
- package/dist/components/Timeline.js.map +1 -1
- package/dist/components/Toggle.js +33 -32
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/Tooltip.js +25 -25
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/Tour.js +126 -126
- package/dist/components/Tour.js.map +1 -1
- package/dist/components/Transfer.js +93 -92
- package/dist/components/Transfer.js.map +1 -1
- package/dist/components/Tree.js +200 -200
- package/dist/components/Tree.js.map +1 -1
- package/dist/components/TreeSelect.js +255 -254
- package/dist/components/TreeSelect.js.map +1 -1
- package/dist/components/Typography.js +71 -70
- package/dist/components/Typography.js.map +1 -1
- package/dist/components/Upload.js +81 -81
- package/dist/components/Upload.js.map +1 -1
- package/dist/components/WeekCalendar.d.ts +35 -0
- package/dist/components/WeekCalendar.js +204 -0
- package/dist/components/WeekCalendar.js.map +1 -0
- package/dist/components/Window.js +7 -7
- package/dist/components/Window.js.map +1 -1
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +5 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +221 -215
- package/dist/index.js.map +1 -1
- package/package.json +30 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":["../../src/components/Modal.tsx"],"sourcesContent":["import React, { useEffect, useRef, useId } from 'react'\nimport { createRoot } from 'react-dom/client'\n\nexport type ModalPosition = 'top' | 'middle' | 'bottom'\nexport type ModalAlign = 'start' | 'end'\nexport type Breakpoint = 'base' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'\n\nexport type ResponsivePosition = Partial<Record<Breakpoint, ModalPosition>>\n\nexport interface ModalProps extends Omit<React.HTMLAttributes<HTMLDialogElement>, 'title'> {\n children: React.ReactNode\n title?: React.ReactNode\n footer?: React.ReactNode\n open?: boolean\n onOk?: () => void | Promise<void>\n onCancel?: () => void\n okText?: string\n cancelText?: string\n maskClosable?: boolean\n closable?: boolean\n /** Modal position - can be a single value or responsive object */\n position?: ModalPosition | ResponsivePosition\n align?: ModalAlign\n /** Width of the modal box */\n width?: number | string\n /** Center the modal vertically */\n centered?: boolean\n /** Callback when modal is closed */\n onClose?: () => void\n /** Where to place initial focus: 'ok', 'cancel', or 'close' button */\n initialFocus?: 'ok' | 'cancel' | 'close'\n /** Use alertdialog role for urgent messages */\n alertDialog?: boolean\n}\n\nexport interface ModalFuncProps {\n title?: React.ReactNode\n content?: React.ReactNode\n onOk?: () => void | Promise<void>\n onCancel?: () => void\n okText?: string\n cancelText?: string\n type?: 'info' | 'success' | 'warning' | 'error'\n}\n\nexport function Modal({\n children,\n title,\n footer,\n open = false,\n onOk,\n onCancel,\n okText = 'OK',\n cancelText = 'Cancel',\n maskClosable = true,\n closable = true,\n position,\n align,\n width,\n centered,\n onClose,\n initialFocus,\n alertDialog = false,\n className = '',\n ...rest\n}: ModalProps) {\n const dialogRef = useRef<HTMLDialogElement>(null)\n const okButtonRef = useRef<HTMLButtonElement>(null)\n const cancelButtonRef = useRef<HTMLButtonElement>(null)\n const closeButtonRef = useRef<HTMLButtonElement>(null)\n const previousActiveElement = useRef<HTMLElement | null>(null)\n const [loading, setLoading] = React.useState(false)\n const titleId = useId()\n const contentId = useId()\n\n // Handle close - use onClose if provided, otherwise onCancel\n const closeHandler = onClose || onCancel\n\n useEffect(() => {\n const dialog = dialogRef.current\n if (!dialog) return\n\n if (open) {\n if (!dialog.open) {\n // Save currently focused element for restoration\n previousActiveElement.current = document.activeElement as HTMLElement\n dialog.showModal()\n\n // Handle custom initial focus placement\n if (initialFocus) {\n setTimeout(() => {\n switch (initialFocus) {\n case 'ok':\n okButtonRef.current?.focus()\n break\n case 'cancel':\n cancelButtonRef.current?.focus()\n break\n case 'close':\n closeButtonRef.current?.focus()\n break\n }\n }, 0)\n }\n }\n } else {\n if (dialog.open) {\n dialog.close()\n // Restore focus to previously focused element\n previousActiveElement.current?.focus()\n }\n }\n }, [open, initialFocus])\n\n useEffect(() => {\n const dialog = dialogRef.current\n if (!dialog) return\n\n const onDialogClose = () => {\n closeHandler?.()\n }\n\n dialog.addEventListener('close', onDialogClose)\n return () => {\n dialog.removeEventListener('close', onDialogClose)\n }\n }, [closeHandler])\n\n // Static class mappings for positions (no interpolation per qa.md)\n const positionClasses: Record<ModalPosition, string> = {\n top: 'modal-top',\n middle: 'modal-middle',\n bottom: 'modal-bottom',\n }\n\n // Responsive position class mappings for each breakpoint\n const responsivePositionClasses: Record<Breakpoint, Record<ModalPosition, string>> = {\n base: {\n top: 'modal-top',\n middle: 'modal-middle',\n bottom: 'modal-bottom',\n },\n sm: {\n top: 'sm:modal-top',\n middle: 'sm:modal-middle',\n bottom: 'sm:modal-bottom',\n },\n md: {\n top: 'md:modal-top',\n middle: 'md:modal-middle',\n bottom: 'md:modal-bottom',\n },\n lg: {\n top: 'lg:modal-top',\n middle: 'lg:modal-middle',\n bottom: 'lg:modal-bottom',\n },\n xl: {\n top: 'xl:modal-top',\n middle: 'xl:modal-middle',\n bottom: 'xl:modal-bottom',\n },\n '2xl': {\n top: '2xl:modal-top',\n middle: '2xl:modal-middle',\n bottom: '2xl:modal-bottom',\n },\n }\n\n const alignClasses: Record<ModalAlign, string> = {\n start: 'modal-start',\n end: 'modal-end',\n }\n\n // Build position classes - handle both simple and responsive values\n const getPositionClasses = (): string[] => {\n // centered is an alias for position=\"middle\"\n if (centered) {\n return [positionClasses.middle]\n }\n\n if (!position) {\n return []\n }\n\n // Simple string position\n if (typeof position === 'string') {\n return [positionClasses[position]]\n }\n\n // Responsive object position\n const classes: string[] = []\n for (const [breakpoint, pos] of Object.entries(position) as [Breakpoint, ModalPosition][]) {\n if (pos) {\n classes.push(responsivePositionClasses[breakpoint][pos])\n }\n }\n return classes\n }\n\n const classes = [\n 'modal',\n ...getPositionClasses(),\n align && alignClasses[align],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const handleOk = async () => {\n if (onOk) {\n setLoading(true)\n try {\n await onOk()\n setLoading(false)\n } catch (error) {\n setLoading(false)\n throw error\n }\n }\n }\n\n const handleBackdropClick = () => {\n if (maskClosable && closeHandler) {\n closeHandler()\n }\n }\n\n // Calculate modal-box style for custom width\n const modalBoxStyle: React.CSSProperties = width\n ? { width: typeof width === 'number' ? `${width}px` : width, maxWidth: '90vw' }\n : {}\n\n // Render default footer if no custom footer provided and either onOk or onCancel exists\n const shouldRenderDefaultFooter = !footer && (onOk || onCancel)\n const shouldRenderCustomFooter = footer !== null && footer !== undefined\n\n return (\n <dialog\n ref={dialogRef}\n role={alertDialog ? 'alertdialog' : 'dialog'}\n aria-modal=\"true\"\n className={classes}\n data-state={open ? 'open' : 'closed'}\n aria-labelledby={title ? titleId : undefined}\n aria-describedby={contentId}\n {...rest}\n >\n <div className=\"modal-box\" style={modalBoxStyle}>\n {title && (\n <h3 id={titleId} className=\"text-lg font-bold mb-4\">\n {title}\n </h3>\n )}\n <div id={contentId} className=\"py-4\">\n {children}\n </div>\n {shouldRenderDefaultFooter && (\n <div className=\"modal-action\">\n {onCancel && (\n <button ref={cancelButtonRef} className=\"btn\" onClick={onCancel}>\n {cancelText}\n </button>\n )}\n {onOk && (\n <button\n ref={okButtonRef}\n className={`btn btn-primary ${loading ? 'loading' : ''}`}\n onClick={handleOk}\n disabled={loading}\n aria-busy={loading || undefined}\n >\n {okText}\n </button>\n )}\n </div>\n )}\n {shouldRenderCustomFooter && <div className=\"modal-action\">{footer}</div>}\n </div>\n {closable && maskClosable && (\n <form method=\"dialog\" className=\"modal-backdrop\">\n <button ref={closeButtonRef} onClick={handleBackdropClick}>\n <span className=\"sr-only\">Close modal</span>\n </button>\n </form>\n )}\n </dialog>\n )\n}\n\nfunction createModal(config: ModalFuncProps & { showCancel?: boolean }) {\n const div = document.createElement('div')\n document.body.appendChild(div)\n const root = createRoot(div)\n\n const destroy = () => {\n root.unmount()\n if (div.parentNode) {\n div.parentNode.removeChild(div)\n }\n }\n\n const ModalContent = () => {\n const [open, setOpen] = React.useState(true)\n const [loading, setLoading] = React.useState(false)\n\n const handleClose = () => {\n setOpen(false)\n setTimeout(destroy, 300) // Wait for animation\n }\n\n const handleOk = async () => {\n if (config.onOk) {\n setLoading(true)\n try {\n await config.onOk()\n handleClose()\n } catch (error) {\n setLoading(false)\n }\n } else {\n handleClose()\n }\n }\n\n const handleCancel = () => {\n config.onCancel?.()\n handleClose()\n }\n\n const getAlertClass = () => {\n switch (config.type) {\n case 'success':\n return 'alert-success'\n case 'warning':\n return 'alert-warning'\n case 'error':\n return 'alert-error'\n case 'info':\n default:\n return 'alert-info'\n }\n }\n\n const getIcon = () => {\n switch (config.type) {\n case 'success':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"stroke-current shrink-0 h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z\"\n />\n </svg>\n )\n case 'warning':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"stroke-current shrink-0 h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n )\n case 'error':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"stroke-current shrink-0 h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z\"\n />\n </svg>\n )\n case 'info':\n default:\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n className=\"stroke-current shrink-0 w-6 h-6\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\"\n ></path>\n </svg>\n )\n }\n }\n\n // Use alertdialog role for warning/error types\n const isAlert = config.type === 'warning' || config.type === 'error'\n\n return (\n <Modal\n open={open}\n onOk={config.showCancel ? undefined : handleOk}\n onCancel={handleCancel}\n alertDialog={isAlert}\n title={\n config.type ? (\n <div className={`alert ${getAlertClass()}`}>\n {getIcon()}\n <div>\n {config.title && <h3 className=\"font-bold\">{config.title}</h3>}\n </div>\n </div>\n ) : (\n config.title\n )\n }\n okText={config.okText}\n cancelText={config.cancelText}\n footer={\n config.showCancel ? (\n <>\n <button className=\"btn\" onClick={handleCancel}>\n {config.cancelText || 'Cancel'}\n </button>\n <button\n className={`btn ${config.type === 'error' ? 'btn-error' : 'btn-primary'} ${loading ? 'loading' : ''}`}\n onClick={handleOk}\n disabled={loading}\n >\n {config.okText || 'OK'}\n </button>\n </>\n ) : (\n <button\n className={`btn ${config.type === 'error' ? 'btn-error' : 'btn-primary'} ${loading ? 'loading' : ''}`}\n onClick={handleOk}\n disabled={loading}\n >\n {config.okText || 'OK'}\n </button>\n )\n }\n >\n {config.type && config.content && <div className=\"text-sm\">{config.content}</div>}\n {!config.type && config.content}\n </Modal>\n )\n }\n\n root.render(<ModalContent />)\n\n return {\n destroy,\n }\n}\n\nfunction confirm(config: ModalFuncProps) {\n return createModal({ ...config, showCancel: true })\n}\n\nfunction info(config: ModalFuncProps) {\n return createModal({ ...config, type: 'info', showCancel: false })\n}\n\nfunction success(config: ModalFuncProps) {\n return createModal({ ...config, type: 'success', showCancel: false })\n}\n\nfunction warning(config: ModalFuncProps) {\n return createModal({ ...config, type: 'warning', showCancel: false })\n}\n\nfunction error(config: ModalFuncProps) {\n return createModal({ ...config, type: 'error', showCancel: false })\n}\n\nModal.confirm = confirm\nModal.info = info\nModal.success = success\nModal.warning = warning\nModal.error = error\n"],"names":["Modal","children","title","footer","open","onOk","onCancel","okText","cancelText","maskClosable","closable","position","align","width","centered","onClose","initialFocus","alertDialog","className","rest","dialogRef","useRef","okButtonRef","cancelButtonRef","closeButtonRef","previousActiveElement","loading","setLoading","React","titleId","useId","contentId","closeHandler","useEffect","dialog","onDialogClose","positionClasses","responsivePositionClasses","alignClasses","classes","breakpoint","pos","handleOk","error","handleBackdropClick","modalBoxStyle","shouldRenderDefaultFooter","shouldRenderCustomFooter","jsxs","jsx","createModal","config","div","root","createRoot","destroy","ModalContent","setOpen","handleClose","handleCancel","getAlertClass","getIcon","isAlert","Fragment","confirm","info","success","warning"],"mappings":";;;AA6CO,SAASA,EAAM;AAAA,EACpB,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,cAAAC,IAAe;AAAA,EACf,UAAAC,IAAW;AAAA,EACX,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,GAAe;AACb,QAAMC,IAAYC,EAA0B,IAAI,GAC1CC,IAAcD,EAA0B,IAAI,GAC5CE,IAAkBF,EAA0B,IAAI,GAChDG,IAAiBH,EAA0B,IAAI,GAC/CI,IAAwBJ,EAA2B,IAAI,GACvD,CAACK,GAASC,CAAU,IAAIC,EAAM,SAAS,EAAK,GAC5CC,IAAUC,EAAA,GACVC,IAAYD,EAAA,GAGZE,IAAejB,KAAWT;AAEhC,EAAA2B,EAAU,MAAM;AACd,UAAMC,IAASd,EAAU;AACzB,IAAKc,MAED9B,IACG8B,EAAO,SAEVT,EAAsB,UAAU,SAAS,eACzCS,EAAO,UAAA,GAGHlB,KACF,WAAW,MAAM;AACf,cAAQA,GAAA;AAAA,QACN,KAAK;AACH,UAAAM,EAAY,SAAS,MAAA;AACrB;AAAA,QACF,KAAK;AACH,UAAAC,EAAgB,SAAS,MAAA;AACzB;AAAA,QACF,KAAK;AACH,UAAAC,EAAe,SAAS,MAAA;AACxB;AAAA,MAAA;AAAA,IAEN,GAAG,CAAC,KAIJU,EAAO,SACTA,EAAO,MAAA,GAEPT,EAAsB,SAAS,MAAA;AAAA,EAGrC,GAAG,CAACrB,GAAMY,C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;AAChBnE,EAAM,QAAQ2C;"}
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":["../../src/components/Modal.tsx"],"sourcesContent":["import React, { useEffect, useRef, useId } from 'react'\nimport { createRoot } from 'react-dom/client'\n\n// DaisyUI classes\nconst dModal = 'modal'\nconst dModalTop = 'modal-top'\nconst dModalMiddle = 'modal-middle'\nconst dModalBottom = 'modal-bottom'\nconst dModalStart = 'modal-start'\nconst dModalEnd = 'modal-end'\nconst dModalBox = 'modal-box'\nconst dModalAction = 'modal-action'\nconst dModalBackdrop = 'modal-backdrop'\nconst dBtn = 'btn'\nconst dBtnPrimary = 'btn-primary'\nconst dBtnError = 'btn-error'\nconst dAlert = 'alert'\nconst dAlertInfo = 'alert-info'\nconst dAlertSuccess = 'alert-success'\nconst dAlertWarning = 'alert-warning'\nconst dAlertError = 'alert-error'\n\nexport type ModalPosition = 'top' | 'middle' | 'bottom'\nexport type ModalAlign = 'start' | 'end'\nexport type Breakpoint = 'base' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'\n\nexport type ResponsivePosition = Partial<Record<Breakpoint, ModalPosition>>\n\nexport interface ModalProps extends Omit<React.HTMLAttributes<HTMLDialogElement>, 'title'> {\n children: React.ReactNode\n title?: React.ReactNode\n footer?: React.ReactNode\n open?: boolean\n onOk?: () => void | Promise<void>\n onCancel?: () => void\n okText?: string\n cancelText?: string\n maskClosable?: boolean\n closable?: boolean\n /** Modal position - can be a single value or responsive object */\n position?: ModalPosition | ResponsivePosition\n align?: ModalAlign\n /** Width of the modal box */\n width?: number | string\n /** Center the modal vertically */\n centered?: boolean\n /** Callback when modal is closed */\n onClose?: () => void\n /** Where to place initial focus: 'ok', 'cancel', or 'close' button */\n initialFocus?: 'ok' | 'cancel' | 'close'\n /** Use alertdialog role for urgent messages */\n alertDialog?: boolean\n}\n\nexport interface ModalFuncProps {\n title?: React.ReactNode\n content?: React.ReactNode\n onOk?: () => void | Promise<void>\n onCancel?: () => void\n okText?: string\n cancelText?: string\n type?: 'info' | 'success' | 'warning' | 'error'\n}\n\nexport function Modal({\n children,\n title,\n footer,\n open = false,\n onOk,\n onCancel,\n okText = 'OK',\n cancelText = 'Cancel',\n maskClosable = true,\n closable = true,\n position,\n align,\n width,\n centered,\n onClose,\n initialFocus,\n alertDialog = false,\n className = '',\n ...rest\n}: ModalProps) {\n const dialogRef = useRef<HTMLDialogElement>(null)\n const okButtonRef = useRef<HTMLButtonElement>(null)\n const cancelButtonRef = useRef<HTMLButtonElement>(null)\n const closeButtonRef = useRef<HTMLButtonElement>(null)\n const previousActiveElement = useRef<HTMLElement | null>(null)\n const [loading, setLoading] = React.useState(false)\n const titleId = useId()\n const contentId = useId()\n\n // Handle close - use onClose if provided, otherwise onCancel\n const closeHandler = onClose || onCancel\n\n useEffect(() => {\n const dialog = dialogRef.current\n if (!dialog) return\n\n if (open) {\n if (!dialog.open) {\n // Save currently focused element for restoration\n previousActiveElement.current = document.activeElement as HTMLElement\n dialog.showModal()\n\n // Handle custom initial focus placement\n if (initialFocus) {\n setTimeout(() => {\n switch (initialFocus) {\n case 'ok':\n okButtonRef.current?.focus()\n break\n case 'cancel':\n cancelButtonRef.current?.focus()\n break\n case 'close':\n closeButtonRef.current?.focus()\n break\n }\n }, 0)\n }\n }\n } else {\n if (dialog.open) {\n dialog.close()\n // Restore focus to previously focused element\n previousActiveElement.current?.focus()\n }\n }\n }, [open, initialFocus])\n\n useEffect(() => {\n const dialog = dialogRef.current\n if (!dialog) return\n\n const onDialogClose = () => {\n closeHandler?.()\n }\n\n dialog.addEventListener('close', onDialogClose)\n return () => {\n dialog.removeEventListener('close', onDialogClose)\n }\n }, [closeHandler])\n\n // Static class mappings for positions (no interpolation per qa.md)\n const positionClasses: Record<ModalPosition, string> = {\n top: dModalTop,\n middle: dModalMiddle,\n bottom: dModalBottom,\n }\n\n // Responsive position class mappings for each breakpoint\n const responsivePositionClasses: Record<Breakpoint, Record<ModalPosition, string>> = {\n base: {\n top: dModalTop,\n middle: dModalMiddle,\n bottom: dModalBottom,\n },\n sm: {\n top: 'sm:modal-top',\n middle: 'sm:modal-middle',\n bottom: 'sm:modal-bottom',\n },\n md: {\n top: 'md:modal-top',\n middle: 'md:modal-middle',\n bottom: 'md:modal-bottom',\n },\n lg: {\n top: 'lg:modal-top',\n middle: 'lg:modal-middle',\n bottom: 'lg:modal-bottom',\n },\n xl: {\n top: 'xl:modal-top',\n middle: 'xl:modal-middle',\n bottom: 'xl:modal-bottom',\n },\n '2xl': {\n top: '2xl:modal-top',\n middle: '2xl:modal-middle',\n bottom: '2xl:modal-bottom',\n },\n }\n\n const alignClasses: Record<ModalAlign, string> = {\n start: dModalStart,\n end: dModalEnd,\n }\n\n // Build position classes - handle both simple and responsive values\n const getPositionClasses = (): string[] => {\n // centered is an alias for position=\"middle\"\n if (centered) {\n return [positionClasses.middle]\n }\n\n if (!position) {\n return []\n }\n\n // Simple string position\n if (typeof position === 'string') {\n return [positionClasses[position]]\n }\n\n // Responsive object position\n const classes: string[] = []\n for (const [breakpoint, pos] of Object.entries(position) as [Breakpoint, ModalPosition][]) {\n if (pos) {\n classes.push(responsivePositionClasses[breakpoint][pos])\n }\n }\n return classes\n }\n\n const classes = [\n dModal,\n ...getPositionClasses(),\n align && alignClasses[align],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const handleOk = async () => {\n if (onOk) {\n setLoading(true)\n try {\n await onOk()\n setLoading(false)\n } catch (error) {\n setLoading(false)\n throw error\n }\n }\n }\n\n const handleBackdropClick = () => {\n if (maskClosable && closeHandler) {\n closeHandler()\n }\n }\n\n // Calculate modal-box style for custom width\n const modalBoxStyle: React.CSSProperties = width\n ? { width: typeof width === 'number' ? `${width}px` : width, maxWidth: '90vw' }\n : {}\n\n // Render default footer if no custom footer provided and either onOk or onCancel exists\n const shouldRenderDefaultFooter = !footer && (onOk || onCancel)\n const shouldRenderCustomFooter = footer !== null && footer !== undefined\n\n return (\n <dialog\n ref={dialogRef}\n role={alertDialog ? 'alertdialog' : 'dialog'}\n aria-modal=\"true\"\n className={classes}\n data-state={open ? 'open' : 'closed'}\n aria-labelledby={title ? titleId : undefined}\n aria-describedby={contentId}\n {...rest}\n >\n <div className={dModalBox} style={modalBoxStyle}>\n {title && (\n <h3 id={titleId} className=\"text-lg font-bold mb-4\">\n {title}\n </h3>\n )}\n <div id={contentId} className=\"py-4\">\n {children}\n </div>\n {shouldRenderDefaultFooter && (\n <div className={dModalAction}>\n {onCancel && (\n <button ref={cancelButtonRef} className={dBtn} onClick={onCancel}>\n {cancelText}\n </button>\n )}\n {onOk && (\n <button\n ref={okButtonRef}\n className={`${dBtn} ${dBtnPrimary} ${loading ? 'loading' : ''}`}\n onClick={handleOk}\n disabled={loading}\n aria-busy={loading || undefined}\n >\n {okText}\n </button>\n )}\n </div>\n )}\n {shouldRenderCustomFooter && <div className={dModalAction}>{footer}</div>}\n </div>\n {closable && maskClosable && (\n <form method=\"dialog\" className={dModalBackdrop}>\n <button ref={closeButtonRef} onClick={handleBackdropClick}>\n <span className=\"sr-only\">Close modal</span>\n </button>\n </form>\n )}\n </dialog>\n )\n}\n\nfunction createModal(config: ModalFuncProps & { showCancel?: boolean }) {\n const div = document.createElement('div')\n document.body.appendChild(div)\n const root = createRoot(div)\n\n const destroy = () => {\n root.unmount()\n if (div.parentNode) {\n div.parentNode.removeChild(div)\n }\n }\n\n const ModalContent = () => {\n const [open, setOpen] = React.useState(true)\n const [loading, setLoading] = React.useState(false)\n\n const handleClose = () => {\n setOpen(false)\n setTimeout(destroy, 300) // Wait for animation\n }\n\n const handleOk = async () => {\n if (config.onOk) {\n setLoading(true)\n try {\n await config.onOk()\n handleClose()\n } catch (error) {\n setLoading(false)\n }\n } else {\n handleClose()\n }\n }\n\n const handleCancel = () => {\n config.onCancel?.()\n handleClose()\n }\n\n const getAlertClass = () => {\n switch (config.type) {\n case 'success':\n return dAlertSuccess\n case 'warning':\n return dAlertWarning\n case 'error':\n return dAlertError\n case 'info':\n default:\n return dAlertInfo\n }\n }\n\n const getIcon = () => {\n switch (config.type) {\n case 'success':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"stroke-current shrink-0 h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z\"\n />\n </svg>\n )\n case 'warning':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"stroke-current shrink-0 h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n )\n case 'error':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"stroke-current shrink-0 h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z\"\n />\n </svg>\n )\n case 'info':\n default:\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n className=\"stroke-current shrink-0 w-6 h-6\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\"\n ></path>\n </svg>\n )\n }\n }\n\n // Use alertdialog role for warning/error types\n const isAlert = config.type === 'warning' || config.type === 'error'\n\n return (\n <Modal\n open={open}\n onOk={config.showCancel ? undefined : handleOk}\n onCancel={handleCancel}\n alertDialog={isAlert}\n title={\n config.type ? (\n <div className={`${dAlert} ${getAlertClass()}`}>\n {getIcon()}\n <div>\n {config.title && <h3 className=\"font-bold\">{config.title}</h3>}\n </div>\n </div>\n ) : (\n config.title\n )\n }\n okText={config.okText}\n cancelText={config.cancelText}\n footer={\n config.showCancel ? (\n <>\n <button className={dBtn} onClick={handleCancel}>\n {config.cancelText || 'Cancel'}\n </button>\n <button\n className={`${dBtn} ${config.type === 'error' ? dBtnError : dBtnPrimary} ${loading ? 'loading' : ''}`}\n onClick={handleOk}\n disabled={loading}\n >\n {config.okText || 'OK'}\n </button>\n </>\n ) : (\n <button\n className={`${dBtn} ${config.type === 'error' ? dBtnError : dBtnPrimary} ${loading ? 'loading' : ''}`}\n onClick={handleOk}\n disabled={loading}\n >\n {config.okText || 'OK'}\n </button>\n )\n }\n >\n {config.type && config.content && <div className=\"text-sm\">{config.content}</div>}\n {!config.type && config.content}\n </Modal>\n )\n }\n\n root.render(<ModalContent />)\n\n return {\n destroy,\n }\n}\n\nfunction confirm(config: ModalFuncProps) {\n return createModal({ ...config, showCancel: true })\n}\n\nfunction info(config: ModalFuncProps) {\n return createModal({ ...config, type: 'info', showCancel: false })\n}\n\nfunction success(config: ModalFuncProps) {\n return createModal({ ...config, type: 'success', showCancel: false })\n}\n\nfunction warning(config: ModalFuncProps) {\n return createModal({ ...config, type: 'warning', showCancel: false })\n}\n\nfunction error(config: ModalFuncProps) {\n return createModal({ ...config, type: 'error', showCancel: false })\n}\n\nModal.confirm = confirm\nModal.info = info\nModal.success = success\nModal.warning = warning\nModal.error = error\n"],"names":["dModal","dModalTop","dModalMiddle","dModalBottom","dModalStart","dModalEnd","dModalBox","dModalAction","dModalBackdrop","dBtn","dBtnPrimary","dBtnError","dAlert","dAlertInfo","dAlertSuccess","dAlertWarning","dAlertError","Modal","children","title","footer","open","onOk","onCancel","okText","cancelText","maskClosable","closable","position","align","width","centered","onClose","initialFocus","alertDialog","className","rest","dialogRef","useRef","okButtonRef","cancelButtonRef","closeButtonRef","previousActiveElement","loading","setLoading","React","titleId","useId","contentId","closeHandler","useEffect","dialog","onDialogClose","positionClasses","responsivePositionClasses","alignClasses","classes","breakpoint","pos","handleOk","error","handleBackdropClick","modalBoxStyle","shouldRenderDefaultFooter","shouldRenderCustomFooter","jsxs","jsx","createModal","config","div","root","createRoot","destroy","ModalContent","setOpen","handleClose","handleCancel","getAlertClass","getIcon","isAlert","Fragment","confirm","info","success","warning"],"mappings":";;;AAIA,MAAMA,KAAS,SACTC,IAAY,aACZC,IAAe,gBACfC,IAAe,gBACfC,KAAc,eACdC,KAAY,aACZC,KAAY,aACZC,IAAe,gBACfC,KAAiB,kBACjBC,IAAO,OACPC,IAAc,eACdC,IAAY,aACZC,KAAS,SACTC,KAAa,cACbC,KAAgB,iBAChBC,KAAgB,iBAChBC,KAAc;AA4Cb,SAASC,EAAM;AAAA,EACpB,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,cAAAC,IAAe;AAAA,EACf,UAAAC,IAAW;AAAA,EACX,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,GAAe;AACb,QAAMC,IAAYC,EAA0B,IAAI,GAC1CC,IAAcD,EAA0B,IAAI,GAC5CE,IAAkBF,EAA0B,IAAI,GAChDG,IAAiBH,EAA0B,IAAI,GAC/CI,IAAwBJ,EAA2B,IAAI,GACvD,CAACK,GAASC,CAAU,IAAIC,EAAM,SAAS,EAAK,G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AAO,gBAAAJ,EAACO,GAAA,CAAA,CAAa,CAAE,GAErB;AAAA,IACL,SAAAD;AAAA,EAAA;AAEJ;AAEA,SAASS,GAAQb,GAAwB;AACvC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,YAAY,IAAM;AACpD;AAEA,SAASc,GAAKd,GAAwB;AACpC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,MAAM,QAAQ,YAAY,IAAO;AACnE;AAEA,SAASe,GAAQf,GAAwB;AACvC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,MAAM,WAAW,YAAY,IAAO;AACtE;AAEA,SAASgB,GAAQhB,GAAwB;AACvC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,MAAM,WAAW,YAAY,IAAO;AACtE;AAEA,SAASR,GAAMQ,GAAwB;AACrC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,MAAM,SAAS,YAAY,IAAO;AACpE;AAEAnD,EAAM,UAAUgE;AAChBhE,EAAM,OAAOiE;AACbjE,EAAM,UAAUkE;AAChBlE,EAAM,UAAUmE;AAChBnE,EAAM,QAAQ2C;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type CalendarEvent = {
|
|
3
|
+
date: Date;
|
|
4
|
+
title: string;
|
|
5
|
+
color: string;
|
|
6
|
+
strikethrough?: boolean;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
};
|
|
9
|
+
export type CalendarLocale = {
|
|
10
|
+
locale: string;
|
|
11
|
+
daysShort: string[];
|
|
12
|
+
monthsLong: string[];
|
|
13
|
+
moreText: string;
|
|
14
|
+
formatTime?: (date: Date) => string;
|
|
15
|
+
};
|
|
16
|
+
export interface MonthCalendarProps<T extends CalendarEvent = CalendarEvent> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
17
|
+
date?: Date;
|
|
18
|
+
events?: T[];
|
|
19
|
+
onEventClick?: (event: T) => void;
|
|
20
|
+
onDayClick?: (date: Date) => void;
|
|
21
|
+
locale?: CalendarLocale;
|
|
22
|
+
allowPastInteraction?: boolean;
|
|
23
|
+
maxEventsPerDay?: number;
|
|
24
|
+
onMoreEventsClick?: (date: Date, events: T[]) => void;
|
|
25
|
+
header?: boolean;
|
|
26
|
+
daySelector?: boolean;
|
|
27
|
+
ellipsis?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const MonthCalendar: <T extends CalendarEvent = CalendarEvent>(props: MonthCalendarProps<T> & {
|
|
30
|
+
ref?: React.ForwardedRef<HTMLDivElement>;
|
|
31
|
+
}) => React.ReactElement;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { jsxs as h, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as H, useState as Y } from "react";
|
|
3
|
+
const A = {
|
|
4
|
+
locale: "en",
|
|
5
|
+
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
6
|
+
monthsLong: [
|
|
7
|
+
"January",
|
|
8
|
+
"February",
|
|
9
|
+
"March",
|
|
10
|
+
"April",
|
|
11
|
+
"May",
|
|
12
|
+
"June",
|
|
13
|
+
"July",
|
|
14
|
+
"August",
|
|
15
|
+
"September",
|
|
16
|
+
"October",
|
|
17
|
+
"November",
|
|
18
|
+
"December"
|
|
19
|
+
],
|
|
20
|
+
moreText: "more"
|
|
21
|
+
}, M = (t) => C(t, /* @__PURE__ */ new Date()), C = (t, e) => {
|
|
22
|
+
const n = new Date(t), r = new Date(e);
|
|
23
|
+
return n.setHours(0, 0, 0, 0), r.setHours(0, 0, 0, 0), r.getTime() === n.getTime();
|
|
24
|
+
}, J = (t) => {
|
|
25
|
+
const e = /* @__PURE__ */ new Date(), n = new Date(t);
|
|
26
|
+
return e.setHours(0, 0, 0, 0), n.setHours(0, 0, 0, 0), n > e;
|
|
27
|
+
}, L = (t) => {
|
|
28
|
+
const e = /* @__PURE__ */ new Date(), n = new Date(t);
|
|
29
|
+
return e.setHours(0, 0, 0, 0), n.setHours(0, 0, 0, 0), n < e;
|
|
30
|
+
}, I = (t, e) => t.filter(
|
|
31
|
+
(n) => n.date.getDate() === e.getDate() && n.date.getMonth() === e.getMonth() && n.date.getFullYear() === e.getFullYear()
|
|
32
|
+
), $ = (t, e) => new Date(t, e + 1, 0).getDate(), q = (t, e) => new Date(t, e, 1).getDay(), z = (t, e) => {
|
|
33
|
+
const n = $(t, e), r = q(t, e), p = [];
|
|
34
|
+
if (r > 0) {
|
|
35
|
+
const o = e === 0 ? 11 : e - 1, a = e === 0 ? t - 1 : t, i = $(a, o);
|
|
36
|
+
for (let g = 0; g < r; g++) {
|
|
37
|
+
const x = i - r + g + 1;
|
|
38
|
+
p.push({
|
|
39
|
+
day: x,
|
|
40
|
+
month: o,
|
|
41
|
+
year: a,
|
|
42
|
+
isCurrentMonth: !1,
|
|
43
|
+
date: new Date(a, o, x)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const d = [];
|
|
48
|
+
for (let o = 1; o <= n; o++)
|
|
49
|
+
d.push({
|
|
50
|
+
day: o,
|
|
51
|
+
month: e,
|
|
52
|
+
year: t,
|
|
53
|
+
isCurrentMonth: !0,
|
|
54
|
+
date: new Date(t, e, o)
|
|
55
|
+
});
|
|
56
|
+
const m = [], u = 42 - (p.length + d.length);
|
|
57
|
+
if (u > 0) {
|
|
58
|
+
const o = e === 11 ? 0 : e + 1, a = e === 11 ? t + 1 : t;
|
|
59
|
+
for (let i = 1; i <= u; i++)
|
|
60
|
+
m.push({
|
|
61
|
+
day: i,
|
|
62
|
+
month: o,
|
|
63
|
+
year: a,
|
|
64
|
+
isCurrentMonth: !1,
|
|
65
|
+
date: new Date(a, o, i)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return [...p, ...d, ...m];
|
|
69
|
+
}, G = H(
|
|
70
|
+
({
|
|
71
|
+
date: t = /* @__PURE__ */ new Date(),
|
|
72
|
+
events: e = [],
|
|
73
|
+
maxEventsPerDay: n = 5,
|
|
74
|
+
onEventClick: r,
|
|
75
|
+
onDayClick: p,
|
|
76
|
+
onMoreEventsClick: d,
|
|
77
|
+
header: m,
|
|
78
|
+
daySelector: D,
|
|
79
|
+
locale: u = A,
|
|
80
|
+
ellipsis: o,
|
|
81
|
+
allowPastInteraction: a = !1,
|
|
82
|
+
className: i = "",
|
|
83
|
+
...g
|
|
84
|
+
}, x) => {
|
|
85
|
+
const [v, T] = Y(/* @__PURE__ */ new Date()), w = t.getFullYear(), N = t.getMonth();
|
|
86
|
+
return /* @__PURE__ */ h(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
ref: x,
|
|
90
|
+
className: `flex h-full w-full flex-col bg-base-100 ${i}`,
|
|
91
|
+
...g,
|
|
92
|
+
children: [
|
|
93
|
+
m && /* @__PURE__ */ l("div", { className: "mb-4 flex items-center justify-between", children: /* @__PURE__ */ l("div", { children: /* @__PURE__ */ h("h2", { className: "m-0 text-lg font-medium text-base-content", children: [
|
|
94
|
+
u.monthsLong[N],
|
|
95
|
+
" ",
|
|
96
|
+
w
|
|
97
|
+
] }) }) }),
|
|
98
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 border-b border-base-300", children: u.daysShort.map((s, b) => /* @__PURE__ */ l(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
className: "py-1 text-center text-xs font-medium uppercase text-base-content/60",
|
|
102
|
+
children: s
|
|
103
|
+
},
|
|
104
|
+
b
|
|
105
|
+
)) }),
|
|
106
|
+
/* @__PURE__ */ l("div", { className: "grid flex-1 grid-cols-7 grid-rows-6 border-l border-base-300", children: z(w, N).map((s, b) => {
|
|
107
|
+
const f = I(e, s.date), y = L(s.date) && !M(s.date), F = D && C(s.date, v);
|
|
108
|
+
return /* @__PURE__ */ h(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
className: `
|
|
112
|
+
relative cursor-pointer overflow-hidden border-b border-r border-base-300 p-1
|
|
113
|
+
hover:bg-base-200
|
|
114
|
+
${s.isCurrentMonth ? "" : "bg-base-200"}
|
|
115
|
+
${M(s.date) ? "bg-primary/10" : ""}
|
|
116
|
+
${y ? "opacity-60" : ""}
|
|
117
|
+
${y && !a ? "cursor-not-allowed" : ""}
|
|
118
|
+
${F ? "z-10 outline outline-2 outline-primary" : ""}
|
|
119
|
+
`,
|
|
120
|
+
onClick: () => {
|
|
121
|
+
y && !a || (D && T(s.date), setTimeout(() => {
|
|
122
|
+
p?.(s.date);
|
|
123
|
+
}, 0));
|
|
124
|
+
},
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ l("div", { className: "mb-0.5 flex justify-center", children: /* @__PURE__ */ l(
|
|
127
|
+
"span",
|
|
128
|
+
{
|
|
129
|
+
className: `
|
|
130
|
+
flex items-center justify-center text-xs leading-none
|
|
131
|
+
${M(s.date) ? "font-bold text-primary" : "text-base-content"}
|
|
132
|
+
${s.isCurrentMonth ? "" : "text-base-content/40"}
|
|
133
|
+
${y && s.isCurrentMonth ? "text-base-content/40" : ""}
|
|
134
|
+
`,
|
|
135
|
+
children: s.day
|
|
136
|
+
}
|
|
137
|
+
) }),
|
|
138
|
+
/* @__PURE__ */ h("div", { className: "flex flex-col", children: [
|
|
139
|
+
f.slice(
|
|
140
|
+
0,
|
|
141
|
+
f.length > n ? n - 1 : n
|
|
142
|
+
).map((c, k) => /* @__PURE__ */ h(
|
|
143
|
+
"div",
|
|
144
|
+
{
|
|
145
|
+
className: `
|
|
146
|
+
flex cursor-pointer items-center rounded px-1 py-0.5 text-xs leading-none
|
|
147
|
+
transition-colors hover:bg-base-content/5
|
|
148
|
+
${J(c.date), "text-base-content"}
|
|
149
|
+
${c.strikethrough ? "line-through" : ""}
|
|
150
|
+
`,
|
|
151
|
+
style: c.style,
|
|
152
|
+
onClick: (S) => {
|
|
153
|
+
S.stopPropagation(), r && r(c);
|
|
154
|
+
},
|
|
155
|
+
title: c.title,
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ l(
|
|
158
|
+
"span",
|
|
159
|
+
{
|
|
160
|
+
className: "mr-1.5 inline-block h-2 w-2 shrink-0 rounded-full",
|
|
161
|
+
style: { backgroundColor: c.color }
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ l(
|
|
165
|
+
"span",
|
|
166
|
+
{
|
|
167
|
+
className: `overflow-hidden whitespace-nowrap ${o ? "text-ellipsis" : ""}`,
|
|
168
|
+
children: c.title
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
k
|
|
174
|
+
)),
|
|
175
|
+
f.length > n && /* @__PURE__ */ h(
|
|
176
|
+
"div",
|
|
177
|
+
{
|
|
178
|
+
className: "cursor-pointer rounded px-1 py-0.5 text-[11px] text-base-content/60 hover:bg-base-content/5",
|
|
179
|
+
onClick: (c) => {
|
|
180
|
+
c.stopPropagation(), d && d(s.date, f);
|
|
181
|
+
},
|
|
182
|
+
children: [
|
|
183
|
+
"+",
|
|
184
|
+
f.length - n + 1,
|
|
185
|
+
" ",
|
|
186
|
+
u.moreText
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
] })
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
b
|
|
194
|
+
);
|
|
195
|
+
}) })
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
G.displayName = "MonthCalendar";
|
|
202
|
+
export {
|
|
203
|
+
G as MonthCalendar
|
|
204
|
+
};
|
|
205
|
+
//# sourceMappingURL=MonthCalendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonthCalendar.js","sources":["../../src/components/MonthCalendar.tsx"],"sourcesContent":["import React, { useState, forwardRef } from 'react'\n\n// DaisyUI classes\n// (No DaisyUI classes used in this component)\n\n// Types\nexport type CalendarEvent = {\n date: Date\n title: string\n color: string\n strikethrough?: boolean\n style?: React.CSSProperties\n}\n\nexport type CalendarLocale = {\n locale: string\n daysShort: string[]\n monthsLong: string[]\n moreText: string\n formatTime?: (date: Date) => string\n}\n\n// Default English locale\nconst defaultLocale: CalendarLocale = {\n locale: 'en',\n daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n monthsLong: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n moreText: 'more',\n}\n\n// Utility functions\nconst isToday = (date: Date) => isEqual(date, new Date())\n\nconst isEqual = (a: Date, b: Date) => {\n const acopy = new Date(a)\n const bcopy = new Date(b)\n acopy.setHours(0, 0, 0, 0)\n bcopy.setHours(0, 0, 0, 0)\n return bcopy.getTime() === acopy.getTime()\n}\n\nconst isFutureDate = (date: Date) => {\n const today = new Date()\n const checkDate = new Date(date)\n today.setHours(0, 0, 0, 0)\n checkDate.setHours(0, 0, 0, 0)\n return checkDate > today\n}\n\nconst isPastDate = (date: Date) => {\n const today = new Date()\n const checkDate = new Date(date)\n today.setHours(0, 0, 0, 0)\n checkDate.setHours(0, 0, 0, 0)\n return checkDate < today\n}\n\nconst getEventsForDate = <T extends CalendarEvent>(events: T[], date: Date) => {\n return events.filter(\n (event) =>\n event.date.getDate() === date.getDate() &&\n event.date.getMonth() === date.getMonth() &&\n event.date.getFullYear() === date.getFullYear()\n )\n}\n\nconst getDaysInMonth = (year: number, month: number) => {\n return new Date(year, month + 1, 0).getDate()\n}\n\nconst getFirstDayOfMonth = (year: number, month: number) => {\n return new Date(year, month, 1).getDay()\n}\n\nconst generateCalendarGrid = (year: number, month: number) => {\n const daysInMonth = getDaysInMonth(year, month)\n const firstDayOfMonth = getFirstDayOfMonth(year, month)\n\n const prevMonthDays = []\n\n if (firstDayOfMonth > 0) {\n const prevMonth = month === 0 ? 11 : month - 1\n const prevMonthYear = month === 0 ? year - 1 : year\n const daysInPrevMonth = getDaysInMonth(prevMonthYear, prevMonth)\n\n for (let i = 0; i < firstDayOfMonth; i++) {\n const day = daysInPrevMonth - firstDayOfMonth + i + 1\n prevMonthDays.push({\n day,\n month: prevMonth,\n year: prevMonthYear,\n isCurrentMonth: false,\n date: new Date(prevMonthYear, prevMonth, day),\n })\n }\n }\n\n const currentMonthDays = []\n\n for (let day = 1; day <= daysInMonth; day++) {\n currentMonthDays.push({\n day,\n month,\n year,\n isCurrentMonth: true,\n date: new Date(year, month, day),\n })\n }\n\n const nextMonthDays = []\n const totalDaysDisplayed = prevMonthDays.length + currentMonthDays.length\n const daysToAdd = 6 * 7 - totalDaysDisplayed\n\n if (daysToAdd > 0) {\n const nextMonth = month === 11 ? 0 : month + 1\n const nextMonthYear = month === 11 ? year + 1 : year\n\n for (let day = 1; day <= daysToAdd; day++) {\n nextMonthDays.push({\n day,\n month: nextMonth,\n year: nextMonthYear,\n isCurrentMonth: false,\n date: new Date(nextMonthYear, nextMonth, day),\n })\n }\n }\n\n return [...prevMonthDays, ...currentMonthDays, ...nextMonthDays]\n}\n\nexport interface MonthCalendarProps<T extends CalendarEvent = CalendarEvent>\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n date?: Date\n events?: T[]\n onEventClick?: (event: T) => void\n onDayClick?: (date: Date) => void\n locale?: CalendarLocale\n allowPastInteraction?: boolean\n maxEventsPerDay?: number\n onMoreEventsClick?: (date: Date, events: T[]) => void\n header?: boolean\n daySelector?: boolean\n ellipsis?: boolean\n}\n\nexport const MonthCalendar = forwardRef<HTMLDivElement, MonthCalendarProps>(\n <T extends CalendarEvent>(\n {\n date = new Date(),\n events = [],\n maxEventsPerDay = 5,\n onEventClick,\n onDayClick,\n onMoreEventsClick,\n header,\n daySelector,\n locale = defaultLocale,\n ellipsis,\n allowPastInteraction = false,\n className = '',\n ...rest\n }: MonthCalendarProps<T>,\n ref: React.ForwardedRef<HTMLDivElement>\n ) => {\n const [selectedDate, setSelectedDate] = useState(new Date())\n\n const year = date.getFullYear()\n const month = date.getMonth()\n\n return (\n <div\n ref={ref}\n className={`flex h-full w-full flex-col bg-base-100 ${className}`}\n {...rest}\n >\n {header && (\n <div className=\"mb-4 flex items-center justify-between\">\n <div>\n <h2 className=\"m-0 text-lg font-medium text-base-content\">\n {locale.monthsLong[month]} {year}\n </h2>\n </div>\n </div>\n )}\n\n {/* Weekday header */}\n <div className=\"grid grid-cols-7 border-b border-base-300\">\n {locale.daysShort.map((day, index) => (\n <div\n key={index}\n className=\"py-1 text-center text-xs font-medium uppercase text-base-content/60\"\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid flex-1 grid-cols-7 grid-rows-6 border-l border-base-300\">\n {generateCalendarGrid(year, month).map((dateObj, index) => {\n const dateEvents = getEventsForDate(events as T[], dateObj.date)\n const isPast = isPastDate(dateObj.date) && !isToday(dateObj.date)\n const isSelected = daySelector && isEqual(dateObj.date, selectedDate)\n\n return (\n <div\n key={index}\n className={`\n relative cursor-pointer overflow-hidden border-b border-r border-base-300 p-1\n hover:bg-base-200\n ${!dateObj.isCurrentMonth ? 'bg-base-200' : ''}\n ${isToday(dateObj.date) ? 'bg-primary/10' : ''}\n ${isPast ? 'opacity-60' : ''}\n ${isPast && !allowPastInteraction ? 'cursor-not-allowed' : ''}\n ${isSelected ? 'z-10 outline outline-2 outline-primary' : ''}\n `}\n onClick={() => {\n if (isPast && !allowPastInteraction) {\n return\n }\n\n if (daySelector) {\n setSelectedDate(dateObj.date)\n }\n\n setTimeout(() => {\n onDayClick?.(dateObj.date)\n }, 0)\n }}\n >\n {/* Date number */}\n <div className=\"mb-0.5 flex justify-center\">\n <span\n className={`\n flex items-center justify-center text-xs leading-none\n ${isToday(dateObj.date) ? 'font-bold text-primary' : 'text-base-content'}\n ${!dateObj.isCurrentMonth ? 'text-base-content/40' : ''}\n ${isPast && dateObj.isCurrentMonth ? 'text-base-content/40' : ''}\n `}\n >\n {dateObj.day}\n </span>\n </div>\n\n {/* Events container */}\n <div className=\"flex flex-col\">\n {dateEvents\n .slice(\n 0,\n dateEvents.length > maxEventsPerDay\n ? maxEventsPerDay - 1\n : maxEventsPerDay\n )\n .map((event, eventIndex) => (\n <div\n key={eventIndex}\n className={`\n flex cursor-pointer items-center rounded px-1 py-0.5 text-xs leading-none\n transition-colors hover:bg-base-content/5\n ${isFutureDate(event.date) ? 'text-base-content' : 'text-base-content'}\n ${event.strikethrough ? 'line-through' : ''}\n `}\n style={event.style}\n onClick={(e) => {\n e.stopPropagation()\n if (onEventClick) {\n onEventClick(event)\n }\n }}\n title={event.title}\n >\n <span\n className=\"mr-1.5 inline-block h-2 w-2 shrink-0 rounded-full\"\n style={{ backgroundColor: event.color }}\n />\n <span\n className={`overflow-hidden whitespace-nowrap ${ellipsis ? 'text-ellipsis' : ''}`}\n >\n {event.title}\n </span>\n </div>\n ))}\n {dateEvents.length > maxEventsPerDay && (\n <div\n className=\"cursor-pointer rounded px-1 py-0.5 text-[11px] text-base-content/60 hover:bg-base-content/5\"\n onClick={(e) => {\n e.stopPropagation()\n if (onMoreEventsClick) {\n onMoreEventsClick(dateObj.date, dateEvents)\n }\n }}\n >\n +{dateEvents.length - maxEventsPerDay + 1} {locale.moreText}\n </div>\n )}\n </div>\n </div>\n )\n })}\n </div>\n </div>\n )\n }\n) as <T extends CalendarEvent = CalendarEvent>(\n props: MonthCalendarProps<T> & { ref?: React.ForwardedRef<HTMLDivElement> }\n) => React.ReactElement\n\n;(MonthCalendar as React.FC).displayName = 'MonthCalendar'\n"],"names":["defaultLocale","isToday","date","isEqual","a","b","acopy","bcopy","isFutureDate","today","checkDate","isPastDate","getEventsForDate","events","event","getDaysInMonth","year","month","getFirstDayOfMonth","generateCalendarGrid","daysInMonth","firstDayOfMonth","prevMonthDays","prevMonth","prevMonthYear","daysInPrevMonth","i","day","currentMonthDays","nextMonthDays","daysToAdd","nextMonth","nextMonthYear","MonthCalendar","forwardRef","maxEventsPerDay","onEventClick","onDayClick","onMoreEventsClick","header","daySelector","locale","ellipsis","allowPastInteraction","className","rest","ref","selectedDate","setSelectedDate","useState","jsxs","jsx","index","dateObj","dateEvents","isPast","isSelected","eventIndex","e"],"mappings":";;AAuBA,MAAMA,IAAgC;AAAA,EACpC,QAAQ;AAAA,EACR,WAAW,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAAA,EAC3D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,UAAU;AACZ,GAGMC,IAAU,CAACC,MAAeC,EAAQD,GAAM,oBAAI,MAAM,GAElDC,IAAU,CAACC,GAASC,MAAY;AACpC,QAAMC,IAAQ,IAAI,KAAKF,CAAC,GAClBG,IAAQ,IAAI,KAAKF,CAAC;AACxB,SAAAC,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GACzBC,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GAClBA,EAAM,cAAcD,EAAM,QAAA;AACnC,GAEME,IAAe,CAACN,MAAe;AACnC,QAAMO,wBAAY,KAAA,GACZC,IAAY,IAAI,KAAKR,CAAI;AAC/B,SAAAO,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GACzBC,EAAU,SAAS,GAAG,GAAG,GAAG,CAAC,GACtBA,IAAYD;AACrB,GAEME,IAAa,CAACT,MAAe;AACjC,QAAMO,wBAAY,KAAA,GACZC,IAAY,IAAI,KAAKR,CAAI;AAC/B,SAAAO,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GACzBC,EAAU,SAAS,GAAG,GAAG,GAAG,CAAC,GACtBA,IAAYD;AACrB,GAEMG,IAAmB,CAA0BC,GAAaX,MACvDW,EAAO;AAAA,EACZ,CAACC,MACCA,EAAM,KAAK,cAAcZ,EAAK,aAC9BY,EAAM,KAAK,eAAeZ,EAAK,cAC/BY,EAAM,KAAK,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YAAA;AAAA,UA4FX,CAAC,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAIEnB,EAA2B,cAAc;"}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
2
|
-
const u = {
|
|
1
|
+
import { jsx as a, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
const i = "navbar", u = "navbar-start", x = "navbar-center", N = "navbar-end", g = {
|
|
3
3
|
base: "bg-base-100",
|
|
4
4
|
neutral: "bg-neutral text-neutral-content",
|
|
5
5
|
primary: "bg-primary text-primary-content",
|
|
6
6
|
secondary: "bg-secondary text-secondary-content",
|
|
7
7
|
accent: "bg-accent text-accent-content"
|
|
8
|
-
},
|
|
8
|
+
}, h = {
|
|
9
9
|
none: "",
|
|
10
10
|
sm: "shadow-sm",
|
|
11
11
|
md: "shadow-md",
|
|
12
12
|
lg: "shadow-lg",
|
|
13
13
|
xl: "shadow-xl"
|
|
14
|
-
},
|
|
14
|
+
}, y = {
|
|
15
15
|
none: "",
|
|
16
16
|
sm: "rounded-sm",
|
|
17
17
|
md: "rounded-md",
|
|
18
18
|
lg: "rounded-lg",
|
|
19
19
|
xl: "rounded-xl",
|
|
20
20
|
full: "rounded-full"
|
|
21
|
-
},
|
|
21
|
+
}, p = ({
|
|
22
22
|
children: n,
|
|
23
|
-
start:
|
|
24
|
-
center:
|
|
25
|
-
end:
|
|
26
|
-
color:
|
|
27
|
-
sticky:
|
|
28
|
-
shadow:
|
|
29
|
-
rounded:
|
|
30
|
-
className:
|
|
31
|
-
...
|
|
23
|
+
start: s,
|
|
24
|
+
center: e,
|
|
25
|
+
end: r,
|
|
26
|
+
color: d = "base",
|
|
27
|
+
sticky: c = !1,
|
|
28
|
+
shadow: l = "none",
|
|
29
|
+
rounded: b = "none",
|
|
30
|
+
className: m = "",
|
|
31
|
+
...o
|
|
32
32
|
}) => {
|
|
33
33
|
const t = [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
i,
|
|
35
|
+
g[d],
|
|
36
|
+
c && "sticky top-0 z-50",
|
|
37
|
+
h[l],
|
|
38
|
+
y[b],
|
|
39
|
+
m
|
|
40
40
|
].filter(Boolean).join(" ");
|
|
41
|
-
return n ? /* @__PURE__ */ a("nav", { className: t, ...
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
return n ? /* @__PURE__ */ a("nav", { className: t, ...o, children: n }) : /* @__PURE__ */ v("nav", { className: t, ...o, children: [
|
|
42
|
+
s && /* @__PURE__ */ a("div", { className: u, children: s }),
|
|
43
|
+
e && /* @__PURE__ */ a("div", { className: x, children: e }),
|
|
44
|
+
r && /* @__PURE__ */ a("div", { className: N, children: r })
|
|
45
45
|
] });
|
|
46
46
|
};
|
|
47
47
|
export {
|
|
48
|
-
|
|
48
|
+
p as Navbar
|
|
49
49
|
};
|
|
50
50
|
//# sourceMappingURL=Navbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navbar.js","sources":["../../src/components/Navbar.tsx"],"sourcesContent":["import React from 'react'\n\nexport type NavbarColor = 'base' | 'neutral' | 'primary' | 'secondary' | 'accent'\nexport type NavbarShadow = 'none' | 'sm' | 'md' | 'lg' | 'xl'\nexport type NavbarRounded = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\nexport interface NavbarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'> {\n children?: React.ReactNode\n /** Content for the start section of the navbar (typically logo/brand) */\n start?: React.ReactNode\n /** Content for the center section of the navbar */\n center?: React.ReactNode\n /** Content for the end section of the navbar (typically actions/menu) */\n end?: React.ReactNode\n /** Background color variant */\n color?: NavbarColor\n /** Make navbar sticky at the top */\n sticky?: boolean\n /** Shadow depth */\n shadow?: NavbarShadow\n /** Border radius */\n rounded?: NavbarRounded\n}\n\nconst colorClasses: Record<NavbarColor, string> = {\n base: 'bg-base-100',\n neutral: 'bg-neutral text-neutral-content',\n primary: 'bg-primary text-primary-content',\n secondary: 'bg-secondary text-secondary-content',\n accent: 'bg-accent text-accent-content',\n}\n\nconst shadowClasses: Record<NavbarShadow, string> = {\n none: '',\n sm: 'shadow-sm',\n md: 'shadow-md',\n lg: 'shadow-lg',\n xl: 'shadow-xl',\n}\n\nconst roundedClasses: Record<NavbarRounded, string> = {\n none: '',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-lg',\n xl: 'rounded-xl',\n full: 'rounded-full',\n}\n\nexport const Navbar: React.FC<NavbarProps> = ({\n children,\n start,\n center,\n end,\n color = 'base',\n sticky = false,\n shadow = 'none',\n rounded = 'none',\n className = '',\n ...rest\n}) => {\n const navbarClasses = [\n
|
|
1
|
+
{"version":3,"file":"Navbar.js","sources":["../../src/components/Navbar.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dNavbar = 'navbar'\nconst dNavbarStart = 'navbar-start'\nconst dNavbarCenter = 'navbar-center'\nconst dNavbarEnd = 'navbar-end'\n\nexport type NavbarColor = 'base' | 'neutral' | 'primary' | 'secondary' | 'accent'\nexport type NavbarShadow = 'none' | 'sm' | 'md' | 'lg' | 'xl'\nexport type NavbarRounded = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\nexport interface NavbarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'> {\n children?: React.ReactNode\n /** Content for the start section of the navbar (typically logo/brand) */\n start?: React.ReactNode\n /** Content for the center section of the navbar */\n center?: React.ReactNode\n /** Content for the end section of the navbar (typically actions/menu) */\n end?: React.ReactNode\n /** Background color variant */\n color?: NavbarColor\n /** Make navbar sticky at the top */\n sticky?: boolean\n /** Shadow depth */\n shadow?: NavbarShadow\n /** Border radius */\n rounded?: NavbarRounded\n}\n\nconst colorClasses: Record<NavbarColor, string> = {\n base: 'bg-base-100',\n neutral: 'bg-neutral text-neutral-content',\n primary: 'bg-primary text-primary-content',\n secondary: 'bg-secondary text-secondary-content',\n accent: 'bg-accent text-accent-content',\n}\n\nconst shadowClasses: Record<NavbarShadow, string> = {\n none: '',\n sm: 'shadow-sm',\n md: 'shadow-md',\n lg: 'shadow-lg',\n xl: 'shadow-xl',\n}\n\nconst roundedClasses: Record<NavbarRounded, string> = {\n none: '',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-lg',\n xl: 'rounded-xl',\n full: 'rounded-full',\n}\n\nexport const Navbar: React.FC<NavbarProps> = ({\n children,\n start,\n center,\n end,\n color = 'base',\n sticky = false,\n shadow = 'none',\n rounded = 'none',\n className = '',\n ...rest\n}) => {\n const navbarClasses = [\n dNavbar,\n colorClasses[color],\n sticky && 'sticky top-0 z-50',\n shadowClasses[shadow],\n roundedClasses[rounded],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n if (children) {\n return <nav className={navbarClasses} {...rest}>{children}</nav>\n }\n\n return (\n <nav className={navbarClasses} {...rest}>\n {start && <div className={dNavbarStart}>{start}</div>}\n {center && <div className={dNavbarCenter}>{center}</div>}\n {end && <div className={dNavbarEnd}>{end}</div>}\n </nav>\n )\n}\n"],"names":["dNavbar","dNavbarStart","dNavbarCenter","dNavbarEnd","colorClasses","shadowClasses","roundedClasses","Navbar","children","start","center","end","color","sticky","shadow","rounded","className","rest","navbarClasses","jsxs","jsx"],"mappings":";AAGA,MAAMA,IAAU,UACVC,IAAe,gBACfC,IAAgB,iBAChBC,IAAa,cAwBbC,IAA4C;AAAA,EAChD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AACV,GAEMC,IAA8C;AAAA,EAClD,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,IAAgD;AAAA,EACpD,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MA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