@linyao.tw/ui 1.1.0 → 1.2.0
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/date-time/calendar.js +1 -0
- package/dist/components/date-time/calendar.js.map +1 -1
- package/dist/components/date-time/date-field.js +1 -0
- package/dist/components/date-time/date-field.js.map +1 -1
- package/dist/components/date-time/date-picker.js +1 -0
- package/dist/components/date-time/date-picker.js.map +1 -1
- package/dist/components/date-time/date-range-picker.js +1 -0
- package/dist/components/date-time/date-range-picker.js.map +1 -1
- package/dist/components/date-time/index.js +1 -0
- package/dist/components/date-time/shared.js +1 -0
- package/dist/components/date-time/shared.js.map +1 -1
- package/dist/components/date-time/time-field.js +1 -0
- package/dist/components/date-time/time-field.js.map +1 -1
- package/dist/components/feedback/alert.js +1 -0
- package/dist/components/feedback/alert.js.map +1 -1
- package/dist/components/feedback/banner.js +1 -0
- package/dist/components/feedback/banner.js.map +1 -1
- package/dist/components/feedback/empty-state.js +1 -0
- package/dist/components/feedback/empty-state.js.map +1 -1
- package/dist/components/feedback/feedback.types.js +1 -0
- package/dist/components/feedback/feedback.types.js.map +1 -1
- package/dist/components/feedback/meter.js +1 -0
- package/dist/components/feedback/meter.js.map +1 -1
- package/dist/components/feedback/progress.js +1 -0
- package/dist/components/feedback/progress.js.map +1 -1
- package/dist/components/feedback/skeleton.js +1 -0
- package/dist/components/feedback/skeleton.js.map +1 -1
- package/dist/components/feedback/spinner.js +1 -0
- package/dist/components/feedback/spinner.js.map +1 -1
- package/dist/components/feedback/toast.js +1 -0
- package/dist/components/feedback/toast.js.map +1 -1
- package/dist/components/forms/code-field.js +1 -0
- package/dist/components/forms/code-field.js.map +1 -1
- package/dist/components/forms/file-upload.js +1 -0
- package/dist/components/forms/file-upload.js.map +1 -1
- package/dist/components/forms/input.js +1 -0
- package/dist/components/forms/input.js.map +1 -1
- package/dist/components/forms/internal.js +12 -10
- package/dist/components/forms/internal.js.map +1 -1
- package/dist/components/forms/number-field.js +1 -0
- package/dist/components/forms/number-field.js.map +1 -1
- package/dist/components/forms/otp-field.js +1 -0
- package/dist/components/forms/otp-field.js.map +1 -1
- package/dist/components/forms/text-field.js +1 -0
- package/dist/components/forms/text-field.js.map +1 -1
- package/dist/components/foundations/avatar.js +10 -7
- package/dist/components/foundations/avatar.js.map +1 -1
- package/dist/components/foundations/badge.js +1 -0
- package/dist/components/foundations/badge.js.map +1 -1
- package/dist/components/foundations/button.js +1 -0
- package/dist/components/foundations/button.js.map +1 -1
- package/dist/components/foundations/card.js +1 -0
- package/dist/components/foundations/card.js.map +1 -1
- package/dist/components/foundations/icon-button.js +1 -0
- package/dist/components/foundations/icon-button.js.map +1 -1
- package/dist/components/foundations/link.js +1 -0
- package/dist/components/foundations/link.js.map +1 -1
- package/dist/components/foundations/list-cell.js +1 -0
- package/dist/components/foundations/list-cell.js.map +1 -1
- package/dist/components/foundations/section-heading.js +1 -0
- package/dist/components/foundations/section-heading.js.map +1 -1
- package/dist/components/foundations/separator.js +1 -0
- package/dist/components/foundations/separator.js.map +1 -1
- package/dist/components/navigation-data/breadcrumb-pagination.js +1 -0
- package/dist/components/navigation-data/breadcrumb-pagination.js.map +1 -1
- package/dist/components/navigation-data/command-palette.js +1 -0
- package/dist/components/navigation-data/command-palette.js.map +1 -1
- package/dist/components/navigation-data/header-tab-bar.js +1 -0
- package/dist/components/navigation-data/header-tab-bar.js.map +1 -1
- package/dist/components/navigation-data/menubar-toolbar.js +1 -0
- package/dist/components/navigation-data/menubar-toolbar.js.map +1 -1
- package/dist/components/navigation-data/navigation-menu.js +1 -0
- package/dist/components/navigation-data/navigation-menu.js.map +1 -1
- package/dist/components/navigation-data/scroll-area.js +1 -0
- package/dist/components/navigation-data/scroll-area.js.map +1 -1
- package/dist/components/navigation-data/table-collection.js +1 -0
- package/dist/components/navigation-data/table-collection.js.map +1 -1
- package/dist/components/overlays/dialog.d.ts +10 -1
- package/dist/components/overlays/dialog.js +11 -8
- package/dist/components/overlays/dialog.js.map +1 -1
- package/dist/components/overlays/disclosure.js +1 -0
- package/dist/components/overlays/disclosure.js.map +1 -1
- package/dist/components/overlays/drawer.d.ts +4 -1
- package/dist/components/overlays/drawer.js +11 -8
- package/dist/components/overlays/drawer.js.map +1 -1
- package/dist/components/overlays/floating.js +1 -0
- package/dist/components/overlays/floating.js.map +1 -1
- package/dist/components/overlays/index.d.ts +1 -1
- package/dist/components/selection/combobox.js +1 -0
- package/dist/components/selection/combobox.js.map +1 -1
- package/dist/components/selection/controls.js +1 -0
- package/dist/components/selection/controls.js.map +1 -1
- package/dist/components/selection/menu.js +1 -0
- package/dist/components/selection/menu.js.map +1 -1
- package/dist/components/selection/select.js +1 -0
- package/dist/components/selection/select.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -32
- package/dist/internal/class-names.js +1 -0
- package/dist/internal/class-names.js.map +1 -1
- package/dist/intl/index.d.ts +1 -0
- package/dist/intl/linyao-provider.d.ts +38 -0
- package/dist/intl/linyao-provider.js +27 -0
- package/dist/intl/linyao-provider.js.map +1 -0
- package/dist/intl/messages.js +1 -0
- package/dist/intl/messages.js.map +1 -1
- package/dist/intl/provider.js +17 -8
- package/dist/intl/provider.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","names":[],"sources":["../../../src/components/overlays/dialog.tsx"],"sourcesContent":["import { AlertDialog as BaseAlertDialog, type AlertDialogRootProps, type AlertDialogTriggerProps } from \"@base-ui/react/alert-dialog\";\nimport {\n\tDialog as BaseDialog,\n\ttype DialogCloseProps as BaseDialogCloseProps,\n\ttype DialogPopupProps as BaseDialogPopupProps,\n\ttype DialogBackdropProps,\n\ttype DialogDescriptionProps,\n\ttype DialogPortalProps,\n\ttype DialogRootProps,\n\ttype DialogTitleProps,\n\ttype DialogTriggerProps,\n\ttype DialogViewportProps\n} from \"@base-ui/react/dialog\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { forwardRef, type HTMLAttributes, type JSX, type ReactNode, type RefAttributes } from \"react\";\n\nimport { cx, withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\nexport type { AlertDialogRootChangeEventDetails } from \"@base-ui/react/alert-dialog\";\nexport type { DialogRootChangeEventDetails } from \"@base-ui/react/dialog\";\n\nfunction CloseGlyph(): JSX.Element {\n\treturn <XIcon aria-hidden=\"true\" className=\"lyds-overlayClose__glyph\" weight=\"bold\" />;\n}\n\nexport function DialogRoot<Payload = unknown>(props: DialogRootProps<Payload>): JSX.Element {\n\treturn <BaseDialog.Root {...props} />;\n}\n\nexport function DialogTrigger<Payload = unknown>({ className, ...props }: DialogTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BaseDialog.Trigger {...props} className={withStateClassName(\"lyds-dialog__trigger\", className)} />;\n}\n\nexport const DialogPortal = forwardRef<HTMLDivElement, DialogPortalProps>(function DialogPortal(props, ref) {\n\treturn <BaseDialog.Portal {...props} ref={ref} />;\n});\n\nexport const DialogBackdrop = forwardRef<HTMLDivElement, DialogBackdropProps>(function DialogBackdrop({ className, ...props }, ref) {\n\treturn <BaseDialog.Backdrop {...props} ref={ref} className={withStateClassName(\"lyds-dialog__backdrop\", className)} />;\n});\n\nexport const DialogViewport = forwardRef<HTMLDivElement, DialogViewportProps>(function DialogViewport({ className, ...props }, ref) {\n\treturn <BaseDialog.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-dialog__viewport\", className)} />;\n});\n\nexport interface DialogPopupProps extends BaseDialogPopupProps {\n\t/** 內建關閉控制項的無障礙標籤。 */\n\tcloseLabel?: string;\n\t/** 傳給內建關閉控制項的屬性。 */\n\tcloseProps?: Omit<DialogCloseProps, \"children\">;\n\t/** Renders the built-in corner close control. */\n\tcloseButton?: boolean;\n\t/**\n\t * @deprecated Pass `closeButton={false}` instead. Kept so existing call sites keep working.\n\t */\n\thasCustomClose?: boolean;\n}\n\nexport const DialogPopup = forwardRef<HTMLDivElement, DialogPopupProps>(function DialogPopup({ children, className, closeButton, closeLabel, closeProps, hasCustomClose = false, ...props }, ref) {\n\tconst messages = useMessages();\n\tconst showCloseButton = closeButton ?? !hasCustomClose;\n\n\treturn (\n\t\t<BaseDialog.Popup {...props} ref={ref} className={withStateClassName(\"lyds-dialog__popup\", className)}>\n\t\t\t{showCloseButton ? <DialogClose {...closeProps} aria-label={closeLabel ?? messages.dialogClose} /> : null}\n\t\t\t{children}\n\t\t</BaseDialog.Popup>\n\t);\n});\n\nexport const DialogTitle = forwardRef<HTMLHeadingElement, DialogTitleProps>(function DialogTitle({ className, ...props }, ref) {\n\treturn <BaseDialog.Title {...props} ref={ref} className={withStateClassName(\"lyds-dialog__title\", className)} />;\n});\n\nexport const DialogDescription = forwardRef<HTMLParagraphElement, DialogDescriptionProps>(function DialogDescription({ className, ...props }, ref) {\n\treturn <BaseDialog.Description {...props} ref={ref} className={withStateClassName(\"lyds-dialog__description\", className)} />;\n});\n\nexport interface DialogCloseProps extends BaseDialogCloseProps {\n\t/** 圖示控制項位於面板角落;動作控制項則參與內容排版。 */\n\tvariant?: \"icon\" | \"action\";\n}\n\nexport const DialogClose = forwardRef<HTMLButtonElement, DialogCloseProps>(function DialogClose(\n\t{ \"aria-label\": ariaLabel, children, className, variant = children == null ? \"icon\" : \"action\", ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\n\treturn (\n\t\t<BaseDialog.Close\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t\taria-label={ariaLabel ?? (children == null ? messages.dialogClose : undefined)}\n\t\t\tclassName={withStateClassName(variant === \"icon\" ? \"lyds-overlayClose\" : \"lyds-overlayCloseAction\", className)}\n\t\t>\n\t\t\t{children ?? <CloseGlyph />}\n\t\t</BaseDialog.Close>\n\t);\n});\n\nexport type DialogHeaderProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DialogHeader = forwardRef<HTMLDivElement, DialogHeaderProps>(function DialogHeader({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-dialog__header\", className)} />;\n});\n\nexport type DialogBodyProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DialogBody = forwardRef<HTMLDivElement, DialogBodyProps>(function DialogBody({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-dialog__body\", className)} />;\n});\n\nexport type DialogFooterProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DialogFooter = forwardRef<HTMLDivElement, DialogFooterProps>(function DialogFooter({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-dialog__footer\", className)} />;\n});\n\nexport const Dialog = {\n\tRoot: DialogRoot,\n\tTrigger: DialogTrigger,\n\tPortal: DialogPortal,\n\tBackdrop: DialogBackdrop,\n\tViewport: DialogViewport,\n\tPopup: DialogPopup,\n\tHeader: DialogHeader,\n\tBody: DialogBody,\n\tFooter: DialogFooter,\n\tTitle: DialogTitle,\n\tDescription: DialogDescription,\n\tClose: DialogClose,\n\tcreateHandle: BaseDialog.createHandle,\n\tHandle: BaseDialog.Handle\n} as const;\n\n/** Base UI 的 Dialog 預設為強制回應;Modal 是用途明確的別名。 */\nexport const Modal = Dialog;\n\nexport function AlertDialogRoot<Payload = unknown>(props: AlertDialogRootProps<Payload>): JSX.Element {\n\treturn <BaseAlertDialog.Root {...props} />;\n}\n\nexport function AlertDialogTrigger<Payload = unknown>({ className, ...props }: AlertDialogTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BaseAlertDialog.Trigger {...props} className={withStateClassName(\"lyds-alertDialog__trigger\", className)} />;\n}\n\nexport interface AlertDialogPopupProps extends BaseDialogPopupProps {\n\t/** 內建取消/關閉控制項的無障礙標籤。 */\n\tcloseLabel?: string;\n\t/** 傳給內建取消/關閉控制項的屬性。 */\n\tcloseProps?: Omit<DialogCloseProps, \"children\">;\n\t/**\n\t * Renders the built-in corner close control. An alert dialog asks for a deliberate choice, so\n\t * this defaults to `false` and the popup should carry its own confirm and cancel actions.\n\t */\n\tcloseButton?: boolean;\n\t/**\n\t * @deprecated Pass `closeButton` instead. Kept so existing call sites keep working.\n\t */\n\thasCustomClose?: boolean;\n}\n\nexport const AlertDialogPopup = forwardRef<HTMLDivElement, AlertDialogPopupProps>(function AlertDialogPopup(\n\t{ children, className, closeButton, closeLabel, closeProps, hasCustomClose, ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\t// The historic default injected a dismiss control; only an explicit hasCustomClose={false} still asks for one.\n\tconst showCloseButton = closeButton ?? hasCustomClose === false;\n\n\treturn (\n\t\t<BaseAlertDialog.Popup {...props} ref={ref} className={withStateClassName(\"lyds-dialog__popup lyds-alertDialog__popup\", className)}>\n\t\t\t{showCloseButton ? <AlertDialogClose {...closeProps} aria-label={closeLabel ?? messages.alertDialogClose} /> : null}\n\t\t\t{children}\n\t\t</BaseAlertDialog.Popup>\n\t);\n});\n\nexport const AlertDialogClose = forwardRef<HTMLButtonElement, DialogCloseProps>(function AlertDialogClose(\n\t{ \"aria-label\": ariaLabel, children, className, variant = children == null ? \"icon\" : \"action\", ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\n\treturn (\n\t\t<BaseAlertDialog.Close\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t\taria-label={ariaLabel ?? (children == null ? messages.alertDialogClose : undefined)}\n\t\t\tclassName={withStateClassName(variant === \"icon\" ? \"lyds-overlayClose\" : \"lyds-overlayCloseAction\", className)}\n\t\t>\n\t\t\t{children ?? <CloseGlyph />}\n\t\t</BaseAlertDialog.Close>\n\t);\n});\n\nexport interface AlertDialogActionsProps extends HTMLAttributes<HTMLDivElement> {\n\tchildren?: ReactNode;\n}\n\nexport const AlertDialogActions = forwardRef<HTMLDivElement, AlertDialogActionsProps>(function AlertDialogActions({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-dialog__footer lyds-alertDialog__actions\", className)} />;\n});\n\nexport const AlertDialog = {\n\tRoot: AlertDialogRoot,\n\tTrigger: AlertDialogTrigger,\n\tPortal: DialogPortal,\n\tBackdrop: DialogBackdrop,\n\tViewport: DialogViewport,\n\tPopup: AlertDialogPopup,\n\tHeader: DialogHeader,\n\tBody: DialogBody,\n\tFooter: DialogFooter,\n\tActions: AlertDialogActions,\n\tTitle: DialogTitle,\n\tDescription: DialogDescription,\n\tClose: AlertDialogClose,\n\tcreateHandle: BaseAlertDialog.createHandle,\n\tHandle: BaseAlertDialog.Handle\n} as const;\n"],"mappings":";;;;;;;;AAqBA,SAAS,IAA0B;CAClC,OAAO,kBAAC,GAAD;EAAO,eAAY;EAAO,WAAU;EAA2B,QAAO;CAAQ,CAAA;AACtF;AAEA,SAAgB,EAA8B,GAA8C;CAC3F,OAAO,kBAAC,EAAW,MAAZ,EAAiB,GAAI,EAAQ,CAAA;AACrC;AAEA,SAAgB,EAAiC,EAAE,cAAW,GAAG,KAAgF;CAChJ,OAAO,kBAAC,EAAW,SAAZ;EAAoB,GAAI;EAAO,WAAW,EAAmB,wBAAwB,CAAS;CAAI,CAAA;AAC1G;AAEA,IAAa,IAAe,EAA8C,SAAsB,GAAO,GAAK;CAC3G,OAAO,kBAAC,EAAW,QAAZ;EAAmB,GAAI;EAAY;CAAM,CAAA;AACjD,CAAC,GAEY,IAAiB,EAAgD,SAAwB,EAAE,cAAW,GAAG,KAAS,GAAK;CACnI,OAAO,kBAAC,EAAW,UAAZ;EAAqB,GAAI;EAAY;EAAK,WAAW,EAAmB,yBAAyB,CAAS;CAAI,CAAA;AACtH,CAAC,GAEY,IAAiB,EAAgD,SAAwB,EAAE,cAAW,GAAG,KAAS,GAAK;CACnI,OAAO,kBAAC,EAAW,UAAZ;EAAqB,GAAI;EAAY;EAAK,WAAW,EAAmB,yBAAyB,CAAS;CAAI,CAAA;AACtH,CAAC,GAeY,IAAc,EAA6C,SAAqB,EAAE,aAAU,cAAW,gBAAa,eAAY,eAAY,oBAAiB,IAAO,GAAG,KAAS,GAAK;CACjM,IAAM,IAAW,EAAY,G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G,UAAA,KAAY,kBAAC,GAAD,CAAa,CAAA;CACJ,CAAA;AAEzB,CAAC,GAMY,IAAqB,EAAoD,SAA4B,EAAE,cAAW,GAAG,KAAS,GAAK;CAC/I,OAAO,kBAAC,OAAD;EAAK,GAAI;EAAY;EAAK,WAAW,EAAG,iDAAiD,CAAS;CAAI,CAAA;AAC9G,CAAC,GAEY,IAAc;CAC1B,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;CACV,UAAU;CACV,OAAO;CACP,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;CACP,cAAc,EAAgB;CAC9B,QAAQ,EAAgB;AACzB"}
|
|
1
|
+
{"version":3,"file":"dialog.js","names":[],"sources":["../../../src/components/overlays/dialog.tsx"],"sourcesContent":["import { AlertDialog as BaseAlertDialog, type AlertDialogRootProps, type AlertDialogTriggerProps } from \"@base-ui/react/alert-dialog\";\nimport {\n\tDialog as BaseDialog,\n\ttype DialogCloseProps as BaseDialogCloseProps,\n\ttype DialogPopupProps as BaseDialogPopupProps,\n\ttype DialogBackdropProps,\n\ttype DialogDescriptionProps,\n\ttype DialogPortalProps,\n\ttype DialogRootProps,\n\ttype DialogTitleProps,\n\ttype DialogTriggerProps,\n\ttype DialogViewportProps\n} from \"@base-ui/react/dialog\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { forwardRef, type HTMLAttributes, type JSX, type ReactNode, type RefAttributes } from \"react\";\n\nimport { cx, withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\nexport type { AlertDialogRootChangeEventDetails } from \"@base-ui/react/alert-dialog\";\nexport type { DialogRootChangeEventDetails } from \"@base-ui/react/dialog\";\n\nfunction CloseGlyph(): JSX.Element {\n\treturn <XIcon aria-hidden=\"true\" className=\"lyds-overlayClose__glyph\" weight=\"bold\" />;\n}\n\nexport function DialogRoot<Payload = unknown>(props: DialogRootProps<Payload>): JSX.Element {\n\treturn <BaseDialog.Root {...props} />;\n}\n\nexport function DialogTrigger<Payload = unknown>({ className, ...props }: DialogTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BaseDialog.Trigger {...props} className={withStateClassName(\"lyds-dialog__trigger\", className)} />;\n}\n\nexport const DialogPortal = forwardRef<HTMLDivElement, DialogPortalProps>(function DialogPortal(props, ref) {\n\treturn <BaseDialog.Portal {...props} ref={ref} />;\n});\n\nexport const DialogBackdrop = forwardRef<HTMLDivElement, DialogBackdropProps>(function DialogBackdrop({ className, ...props }, ref) {\n\treturn <BaseDialog.Backdrop {...props} ref={ref} className={withStateClassName(\"lyds-dialog__backdrop\", className)} />;\n});\n\nexport const DialogViewport = forwardRef<HTMLDivElement, DialogViewportProps>(function DialogViewport({ className, ...props }, ref) {\n\treturn <BaseDialog.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-dialog__viewport\", className)} />;\n});\n\nexport interface DialogPopupProps extends BaseDialogPopupProps {\n\t/** 內建關閉控制項的無障礙標籤。 */\n\tcloseLabel?: string;\n\t/** 傳給內建關閉控制項的屬性。 */\n\tcloseProps?: Omit<DialogCloseProps, \"children\">;\n\t/** Renders the built-in corner close control. */\n\tcloseButton?: boolean;\n\t/**\n\t * @deprecated Pass `closeButton={false}` instead. Kept so existing call sites keep working.\n\t */\n\thasCustomClose?: boolean;\n}\n\nexport const DialogPopup = forwardRef<HTMLDivElement, DialogPopupProps>(function DialogPopup({ children, className, closeButton, closeLabel, closeProps, hasCustomClose = false, ...props }, ref) {\n\tconst messages = useMessages();\n\tconst showCloseButton = closeButton ?? !hasCustomClose;\n\n\treturn (\n\t\t<BaseDialog.Popup {...props} ref={ref} className={withStateClassName(\"lyds-dialog__popup\", className)}>\n\t\t\t{showCloseButton ? <DialogClose {...closeProps} aria-label={closeLabel ?? messages.dialogClose} /> : null}\n\t\t\t{children}\n\t\t</BaseDialog.Popup>\n\t);\n});\n\nexport const DialogTitle = forwardRef<HTMLHeadingElement, DialogTitleProps>(function DialogTitle({ className, ...props }, ref) {\n\treturn <BaseDialog.Title {...props} ref={ref} className={withStateClassName(\"lyds-dialog__title\", className)} />;\n});\n\nexport const DialogDescription = forwardRef<HTMLParagraphElement, DialogDescriptionProps>(function DialogDescription({ className, ...props }, ref) {\n\treturn <BaseDialog.Description {...props} ref={ref} className={withStateClassName(\"lyds-dialog__description\", className)} />;\n});\n\nexport interface DialogCloseProps extends BaseDialogCloseProps {\n\t/** 圖示控制項位於面板角落;動作控制項則參與內容排版。 */\n\tvariant?: \"icon\" | \"action\";\n}\n\nexport const DialogClose = forwardRef<HTMLButtonElement, DialogCloseProps>(function DialogClose(\n\t{ \"aria-label\": ariaLabel, children, className, variant = children == null ? \"icon\" : \"action\", ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\n\treturn (\n\t\t<BaseDialog.Close\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t\taria-label={ariaLabel ?? (children == null ? messages.dialogClose : undefined)}\n\t\t\tclassName={withStateClassName(variant === \"icon\" ? \"lyds-overlayClose\" : \"lyds-overlayCloseAction\", className)}\n\t\t>\n\t\t\t{children ?? <CloseGlyph />}\n\t\t</BaseDialog.Close>\n\t);\n});\n\nexport type DialogHeaderProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DialogHeader = forwardRef<HTMLDivElement, DialogHeaderProps>(function DialogHeader({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-dialog__header\", className)} />;\n});\n\nexport type DialogBodyProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DialogBody = forwardRef<HTMLDivElement, DialogBodyProps>(function DialogBody({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-dialog__body\", className)} />;\n});\n\n/**\n * `stretch`, the default, gives every child an equal column so a Cancel/Confirm pair reads as\n * one balanced decision. `end` sizes the actions to their own labels and puts them at the end\n * of the row; `between` separates supporting copy from the actions.\n */\nexport type OverlayFooterAlign = \"end\" | \"between\" | \"stretch\";\n\nexport interface DialogFooterProps extends HTMLAttributes<HTMLDivElement> {\n\talign?: OverlayFooterAlign;\n}\n\nexport const DialogFooter = forwardRef<HTMLDivElement, DialogFooterProps>(function DialogFooter({ align = \"stretch\", className, ...props }, ref) {\n\treturn <div {...props} ref={ref} data-align={align} className={cx(\"lyds-dialog__footer\", className)} />;\n});\n\nexport const Dialog = {\n\tRoot: DialogRoot,\n\tTrigger: DialogTrigger,\n\tPortal: DialogPortal,\n\tBackdrop: DialogBackdrop,\n\tViewport: DialogViewport,\n\tPopup: DialogPopup,\n\tHeader: DialogHeader,\n\tBody: DialogBody,\n\tFooter: DialogFooter,\n\tTitle: DialogTitle,\n\tDescription: DialogDescription,\n\tClose: DialogClose,\n\tcreateHandle: BaseDialog.createHandle,\n\tHandle: BaseDialog.Handle\n} as const;\n\n/** Base UI 的 Dialog 預設為強制回應;Modal 是用途明確的別名。 */\nexport const Modal = Dialog;\n\nexport function AlertDialogRoot<Payload = unknown>(props: AlertDialogRootProps<Payload>): JSX.Element {\n\treturn <BaseAlertDialog.Root {...props} />;\n}\n\nexport function AlertDialogTrigger<Payload = unknown>({ className, ...props }: AlertDialogTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BaseAlertDialog.Trigger {...props} className={withStateClassName(\"lyds-alertDialog__trigger\", className)} />;\n}\n\nexport interface AlertDialogPopupProps extends BaseDialogPopupProps {\n\t/** 內建取消/關閉控制項的無障礙標籤。 */\n\tcloseLabel?: string;\n\t/** 傳給內建取消/關閉控制項的屬性。 */\n\tcloseProps?: Omit<DialogCloseProps, \"children\">;\n\t/**\n\t * Renders the built-in corner close control. An alert dialog asks for a deliberate choice, so\n\t * this defaults to `false` and the popup should carry its own confirm and cancel actions.\n\t */\n\tcloseButton?: boolean;\n\t/**\n\t * @deprecated Pass `closeButton` instead. Kept so existing call sites keep working.\n\t */\n\thasCustomClose?: boolean;\n}\n\nexport const AlertDialogPopup = forwardRef<HTMLDivElement, AlertDialogPopupProps>(function AlertDialogPopup(\n\t{ children, className, closeButton, closeLabel, closeProps, hasCustomClose, ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\t// The historic default injected a dismiss control; only an explicit hasCustomClose={false} still asks for one.\n\tconst showCloseButton = closeButton ?? hasCustomClose === false;\n\n\treturn (\n\t\t<BaseAlertDialog.Popup {...props} ref={ref} className={withStateClassName(\"lyds-dialog__popup lyds-alertDialog__popup\", className)}>\n\t\t\t{showCloseButton ? <AlertDialogClose {...closeProps} aria-label={closeLabel ?? messages.alertDialogClose} /> : null}\n\t\t\t{children}\n\t\t</BaseAlertDialog.Popup>\n\t);\n});\n\nexport const AlertDialogClose = forwardRef<HTMLButtonElement, DialogCloseProps>(function AlertDialogClose(\n\t{ \"aria-label\": ariaLabel, children, className, variant = children == null ? \"icon\" : \"action\", ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\n\treturn (\n\t\t<BaseAlertDialog.Close\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t\taria-label={ariaLabel ?? (children == null ? messages.alertDialogClose : undefined)}\n\t\t\tclassName={withStateClassName(variant === \"icon\" ? \"lyds-overlayClose\" : \"lyds-overlayCloseAction\", className)}\n\t\t>\n\t\t\t{children ?? <CloseGlyph />}\n\t\t</BaseAlertDialog.Close>\n\t);\n});\n\nexport interface AlertDialogActionsProps extends HTMLAttributes<HTMLDivElement> {\n\tchildren?: ReactNode;\n\talign?: OverlayFooterAlign;\n}\n\nexport const AlertDialogActions = forwardRef<HTMLDivElement, AlertDialogActionsProps>(function AlertDialogActions({ align = \"stretch\", className, ...props }, ref) {\n\treturn <div {...props} ref={ref} data-align={align} className={cx(\"lyds-dialog__footer lyds-alertDialog__actions\", className)} />;\n});\n\nexport const AlertDialog = {\n\tRoot: AlertDialogRoot,\n\tTrigger: AlertDialogTrigger,\n\tPortal: DialogPortal,\n\tBackdrop: DialogBackdrop,\n\tViewport: DialogViewport,\n\tPopup: AlertDialogPopup,\n\tHeader: DialogHeader,\n\tBody: DialogBody,\n\tFooter: DialogFooter,\n\tActions: AlertDialogActions,\n\tTitle: DialogTitle,\n\tDescription: DialogDescription,\n\tClose: AlertDialogClose,\n\tcreateHandle: BaseAlertDialog.createHandle,\n\tHandle: BaseAlertDialog.Handle\n} as const;\n"],"mappings":";;;;;;;;;AAqBA,SAAS,IAA0B;CAClC,OAAO,kBAAC,GAAD;EAAO,eAAY;EAAO,WAAU;EAA2B,QAAO;CAAQ,CAAA;AACtF;AAEA,SAAgB,EAA8B,GAA8C;CAC3F,OAAO,kBAAC,EAAW,MAAZ,EAAiB,GAAI,EAAQ,CAAA;AACrC;AAEA,SAAgB,EAAiC,EAAE,cAAW,GAAG,KAAgF;CAChJ,OAAO,kBAAC,EAAW,SAAZ;EAAoB,GAAI;EAAO,WAAW,EAAmB,wBAAwB,CAAS;CAAI,CAAA;AAC1G;AAEA,IAAa,IAAe,EAA8C,SAAsB,GAAO,GAAK;CAC3G,OAAO,kBAAC,EAAW,QAAZ;EAAmB,GAAI;EAAY;CAAM,CAAA;AACjD,CAAC,GAEY,IAAiB,EAAgD,SAAwB,EAAE,cAAW,GAAG,KAAS,GAAK;CACnI,OAAO,kBAAC,EAAW,UAAZ;EAAqB,GAAI;EAAY;EAAK,WAAW,EAAmB,yBAAyB,CAAS;CAAI,CAAA;AACtH,CAAC,GAEY,IAAiB,EAAgD,SAAwB,EAAE,cAAW,GAAG,KAAS,GAAK;CACnI,OAAO,kBAAC,EAAW,UAAZ;EAAqB,GAAI;EAAY;EAAK,WAAW,EAAmB,yBAAyB,CAAS;CAAI,CAAA;AACtH,CAAC,GAeY,IAAc,EAA6C,SAAqB,EAAE,aAAU,cAAW,gBAAa,eAAY,eAAY,oBAAiB,IAAO,GAAG,KAAS,GAAK;CACjM,IAAM,IAAW,EAAY,GACvB,IAAkB,KAAe,CAAC;CAExC,OACC,kBAAC,EAAW,OAAZ;EAAkB,GAAI;EAAY;EAAK,WAAW,EAAmB,sBAAsB,CAAS;EAApG,UAAA,CACE,IAAkB,kBAAC,G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W,GAAG,KAAS,GAAK;CAClK,OAAO,kBAAC,OAAD;EAAK,GAAI;EAAY;EAAK,cAAY;EAAO,WAAW,EAAG,iDAAiD,CAAS;CAAI,CAAA;AACjI,CAAC,GAEY,IAAc;CAC1B,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;CACV,UAAU;CACV,OAAO;CACP,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;CACP,cAAc,EAAgB;CAC9B,QAAQ,EAAgB;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disclosure.js","names":[],"sources":["../../../src/components/overlays/disclosure.tsx"],"sourcesContent":["import {\n\tAccordion as BaseAccordion,\n\ttype AccordionHeaderProps,\n\ttype AccordionItemProps,\n\ttype AccordionPanelProps,\n\ttype AccordionRootProps,\n\ttype AccordionTriggerProps\n} from \"@base-ui/react/accordion\";\nimport { Collapsible as BaseCollapsible, type CollapsiblePanelProps, type CollapsibleRootProps, type CollapsibleTriggerProps } from \"@base-ui/react/collapsible\";\nimport { Tabs as BaseTabs, type TabsIndicatorProps, type TabsListProps, type TabsPanelProps, type TabsRootProps, type TabsTabProps } from \"@base-ui/react/tabs\";\nimport { CaretDownIcon } from \"@phosphor-icons/react/dist/csr/CaretDown\";\nimport { forwardRef, type JSX } from \"react\";\n\nimport { withStateClassName } from \"@/internal\";\nexport type { AccordionRootChangeEventDetails } from \"@base-ui/react/accordion\";\nexport type { CollapsibleRootChangeEventDetails } from \"@base-ui/react/collapsible\";\nexport type { TabsRootChangeEventDetails } from \"@base-ui/react/tabs\";\n\nexport function AccordionRoot<Value = string>(props: AccordionRootProps<Value>): JSX.Element {\n\tconst { className, ...rootProps } = props;\n\n\treturn <BaseAccordion.Root {...rootProps} className={withStateClassName(\"lyds-accordion\", className)} />;\n}\n\nexport const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(function AccordionItem({ className, ...props }, ref) {\n\treturn <BaseAccordion.Item {...props} ref={ref} className={withStateClassName(\"lyds-accordion__item\", className)} />;\n});\n\nexport const AccordionHeader = forwardRef<HTMLHeadingElement, AccordionHeaderProps>(function AccordionHeader({ className, ...props }, ref) {\n\treturn <BaseAccordion.Header {...props} ref={ref} className={withStateClassName(\"lyds-accordion__header\", className)} />;\n});\n\nexport const AccordionTrigger = forwardRef<HTMLElement, AccordionTriggerProps>(function AccordionTrigger({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseAccordion.Trigger {...props} ref={ref} className={withStateClassName(\"lyds-accordion__trigger\", className)}>\n\t\t\t<span className=\"lyds-accordion__label\">{children}</span>\n\t\t\t<span className=\"lyds-accordion__indicator\" aria-hidden=\"true\">\n\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t</span>\n\t\t</BaseAccordion.Trigger>\n\t);\n});\n\nexport const AccordionPanel = forwardRef<HTMLDivElement, AccordionPanelProps>(function AccordionPanel({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseAccordion.Panel {...props} ref={ref} className={withStateClassName(\"lyds-accordion__panel\", className)}>\n\t\t\t<div className=\"lyds-accordion__panelContent\">{children}</div>\n\t\t</BaseAccordion.Panel>\n\t);\n});\n\nexport const Accordion = {\n\tRoot: AccordionRoot,\n\tItem: AccordionItem,\n\tHeader: AccordionHeader,\n\tTrigger: AccordionTrigger,\n\tPanel: AccordionPanel\n} as const;\n\nexport const CollapsibleRoot = forwardRef<HTMLDivElement, CollapsibleRootProps>(function CollapsibleRoot({ className, ...props }, ref) {\n\treturn <BaseCollapsible.Root {...props} ref={ref} className={withStateClassName(\"lyds-collapsible\", className)} />;\n});\n\nexport const CollapsibleTrigger = forwardRef<HTMLButtonElement, CollapsibleTriggerProps>(function CollapsibleTrigger({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseCollapsible.Trigger {...props} ref={ref} className={withStateClassName(\"lyds-collapsible__trigger\", className)}>\n\t\t\t<span className=\"lyds-collapsible__label\">{children}</span>\n\t\t\t<span className=\"lyds-collapsible__indicator\" aria-hidden=\"true\">\n\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t</span>\n\t\t</BaseCollapsible.Trigger>\n\t);\n});\n\nexport const CollapsiblePanel = forwardRef<HTMLDivElement, CollapsiblePanelProps>(function CollapsiblePanel({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseCollapsible.Panel {...props} ref={ref} className={withStateClassName(\"lyds-collapsible__panel\", className)}>\n\t\t\t<div className=\"lyds-collapsible__panelContent\">{children}</div>\n\t\t</BaseCollapsible.Panel>\n\t);\n});\n\nexport const Collapsible = {\n\tRoot: CollapsibleRoot,\n\tTrigger: CollapsibleTrigger,\n\tPanel: CollapsiblePanel\n} as const;\n\nexport const TabsRoot = forwardRef<HTMLDivElement, TabsRootProps>(function TabsRoot({ className, ...props }, ref) {\n\treturn <BaseTabs.Root {...props} ref={ref} className={withStateClassName(\"lyds-tabs\", className)} />;\n});\n\nexport const TabsList = forwardRef<HTMLDivElement, TabsListProps>(function TabsList({ className, ...props }, ref) {\n\treturn <BaseTabs.List {...props} ref={ref} className={withStateClassName(\"lyds-tabs__list\", className)} />;\n});\n\nexport const TabsTab = forwardRef<HTMLElement, TabsTabProps>(function TabsTab({ className, ...props }, ref) {\n\treturn <BaseTabs.Tab {...props} ref={ref} className={withStateClassName(\"lyds-tabs__tab\", className)} />;\n});\n\n/** Base UI 指示器的進階自訂介面。作用中的分頁已有自身選取樣式,因此 Linyao Design System 預設隱藏此元件。 */\nexport const TabsIndicator = forwardRef<HTMLSpanElement, TabsIndicatorProps>(function TabsIndicator({ className, ...props }, ref) {\n\treturn <BaseTabs.Indicator {...props} ref={ref} className={withStateClassName(\"lyds-tabs__indicator\", className)} />;\n});\n\nexport const TabsPanel = forwardRef<HTMLDivElement, TabsPanelProps>(function TabsPanel({ className, ...props }, ref) {\n\treturn <BaseTabs.Panel {...props} ref={ref} className={withStateClassName(\"lyds-tabs__panel\", className)} />;\n});\n\nexport const Tabs = {\n\tRoot: TabsRoot,\n\tList: TabsList,\n\tTab: TabsTab,\n\tIndicator: TabsIndicator,\n\tPanel: TabsPanel\n} as const;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"disclosure.js","names":[],"sources":["../../../src/components/overlays/disclosure.tsx"],"sourcesContent":["import {\n\tAccordion as BaseAccordion,\n\ttype AccordionHeaderProps,\n\ttype AccordionItemProps,\n\ttype AccordionPanelProps,\n\ttype AccordionRootProps,\n\ttype AccordionTriggerProps\n} from \"@base-ui/react/accordion\";\nimport { Collapsible as BaseCollapsible, type CollapsiblePanelProps, type CollapsibleRootProps, type CollapsibleTriggerProps } from \"@base-ui/react/collapsible\";\nimport { Tabs as BaseTabs, type TabsIndicatorProps, type TabsListProps, type TabsPanelProps, type TabsRootProps, type TabsTabProps } from \"@base-ui/react/tabs\";\nimport { CaretDownIcon } from \"@phosphor-icons/react/dist/csr/CaretDown\";\nimport { forwardRef, type JSX } from \"react\";\n\nimport { withStateClassName } from \"@/internal\";\nexport type { AccordionRootChangeEventDetails } from \"@base-ui/react/accordion\";\nexport type { CollapsibleRootChangeEventDetails } from \"@base-ui/react/collapsible\";\nexport type { TabsRootChangeEventDetails } from \"@base-ui/react/tabs\";\n\nexport function AccordionRoot<Value = string>(props: AccordionRootProps<Value>): JSX.Element {\n\tconst { className, ...rootProps } = props;\n\n\treturn <BaseAccordion.Root {...rootProps} className={withStateClassName(\"lyds-accordion\", className)} />;\n}\n\nexport const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(function AccordionItem({ className, ...props }, ref) {\n\treturn <BaseAccordion.Item {...props} ref={ref} className={withStateClassName(\"lyds-accordion__item\", className)} />;\n});\n\nexport const AccordionHeader = forwardRef<HTMLHeadingElement, AccordionHeaderProps>(function AccordionHeader({ className, ...props }, ref) {\n\treturn <BaseAccordion.Header {...props} ref={ref} className={withStateClassName(\"lyds-accordion__header\", className)} />;\n});\n\nexport const AccordionTrigger = forwardRef<HTMLElement, AccordionTriggerProps>(function AccordionTrigger({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseAccordion.Trigger {...props} ref={ref} className={withStateClassName(\"lyds-accordion__trigger\", className)}>\n\t\t\t<span className=\"lyds-accordion__label\">{children}</span>\n\t\t\t<span className=\"lyds-accordion__indicator\" aria-hidden=\"true\">\n\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t</span>\n\t\t</BaseAccordion.Trigger>\n\t);\n});\n\nexport const AccordionPanel = forwardRef<HTMLDivElement, AccordionPanelProps>(function AccordionPanel({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseAccordion.Panel {...props} ref={ref} className={withStateClassName(\"lyds-accordion__panel\", className)}>\n\t\t\t<div className=\"lyds-accordion__panelContent\">{children}</div>\n\t\t</BaseAccordion.Panel>\n\t);\n});\n\nexport const Accordion = {\n\tRoot: AccordionRoot,\n\tItem: AccordionItem,\n\tHeader: AccordionHeader,\n\tTrigger: AccordionTrigger,\n\tPanel: AccordionPanel\n} as const;\n\nexport const CollapsibleRoot = forwardRef<HTMLDivElement, CollapsibleRootProps>(function CollapsibleRoot({ className, ...props }, ref) {\n\treturn <BaseCollapsible.Root {...props} ref={ref} className={withStateClassName(\"lyds-collapsible\", className)} />;\n});\n\nexport const CollapsibleTrigger = forwardRef<HTMLButtonElement, CollapsibleTriggerProps>(function CollapsibleTrigger({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseCollapsible.Trigger {...props} ref={ref} className={withStateClassName(\"lyds-collapsible__trigger\", className)}>\n\t\t\t<span className=\"lyds-collapsible__label\">{children}</span>\n\t\t\t<span className=\"lyds-collapsible__indicator\" aria-hidden=\"true\">\n\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t</span>\n\t\t</BaseCollapsible.Trigger>\n\t);\n});\n\nexport const CollapsiblePanel = forwardRef<HTMLDivElement, CollapsiblePanelProps>(function CollapsiblePanel({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseCollapsible.Panel {...props} ref={ref} className={withStateClassName(\"lyds-collapsible__panel\", className)}>\n\t\t\t<div className=\"lyds-collapsible__panelContent\">{children}</div>\n\t\t</BaseCollapsible.Panel>\n\t);\n});\n\nexport const Collapsible = {\n\tRoot: CollapsibleRoot,\n\tTrigger: CollapsibleTrigger,\n\tPanel: CollapsiblePanel\n} as const;\n\nexport const TabsRoot = forwardRef<HTMLDivElement, TabsRootProps>(function TabsRoot({ className, ...props }, ref) {\n\treturn <BaseTabs.Root {...props} ref={ref} className={withStateClassName(\"lyds-tabs\", className)} />;\n});\n\nexport const TabsList = forwardRef<HTMLDivElement, TabsListProps>(function TabsList({ className, ...props }, ref) {\n\treturn <BaseTabs.List {...props} ref={ref} className={withStateClassName(\"lyds-tabs__list\", className)} />;\n});\n\nexport const TabsTab = forwardRef<HTMLElement, TabsTabProps>(function TabsTab({ className, ...props }, ref) {\n\treturn <BaseTabs.Tab {...props} ref={ref} className={withStateClassName(\"lyds-tabs__tab\", className)} />;\n});\n\n/** Base UI 指示器的進階自訂介面。作用中的分頁已有自身選取樣式,因此 Linyao Design System 預設隱藏此元件。 */\nexport const TabsIndicator = forwardRef<HTMLSpanElement, TabsIndicatorProps>(function TabsIndicator({ className, ...props }, ref) {\n\treturn <BaseTabs.Indicator {...props} ref={ref} className={withStateClassName(\"lyds-tabs__indicator\", className)} />;\n});\n\nexport const TabsPanel = forwardRef<HTMLDivElement, TabsPanelProps>(function TabsPanel({ className, ...props }, ref) {\n\treturn <BaseTabs.Panel {...props} ref={ref} className={withStateClassName(\"lyds-tabs__panel\", className)} />;\n});\n\nexport const Tabs = {\n\tRoot: TabsRoot,\n\tList: TabsList,\n\tTab: TabsTab,\n\tIndicator: TabsIndicator,\n\tPanel: TabsPanel\n} as const;\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,EAA8B,GAA+C;CAC5F,IAAM,EAAE,cAAW,GAAG,MAAc;CAEpC,OAAO,kBAAC,EAAc,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I;EAAY;EAAK,WAAW,EAAmB,wBAAwB,CAAS;CAAI,CAAA;AACpH,CAAC,GAEY,IAAY,EAA2C,SAAmB,EAAE,cAAW,GAAG,KAAS,GAAK;CACpH,OAAO,kBAAC,EAAS,OAAV;EAAgB,GAAI;EAAY;EAAK,WAAW,EAAmB,oBAAoB,CAAS;CAAI,CAAA;AAC5G,CAAC,GAEY,IAAO;CACnB,MAAM;CACN,MAAM;CACN,KAAK;CACL,WAAW;CACX,OAAO;AACR"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Drawer as BaseDrawer, DrawerCloseProps as BaseDrawerCloseProps, DrawerPopupProps as BaseDrawerPopupProps, DrawerBackdropProps, DrawerContentProps, DrawerDescriptionProps, DrawerPortalProps, DrawerRootProps, DrawerSwipeAreaProps, DrawerTitleProps, DrawerTriggerProps, DrawerViewportProps } from '@base-ui/react/drawer';
|
|
2
2
|
import { HTMLAttributes, JSX, RefAttributes } from 'react';
|
|
3
|
+
import { OverlayFooterAlign } from './dialog.js';
|
|
3
4
|
export type { DrawerRootChangeEventDetails } from '@base-ui/react/drawer';
|
|
4
5
|
export declare function DrawerRoot<Payload = unknown>({ swipeDirection, ...props }: DrawerRootProps<Payload>): JSX.Element;
|
|
5
6
|
export declare function DrawerTrigger<Payload = unknown>({ className, ...props }: DrawerTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element;
|
|
@@ -32,7 +33,9 @@ export type DrawerHeaderProps = HTMLAttributes<HTMLDivElement>;
|
|
|
32
33
|
export declare const DrawerHeader: import('react').ForwardRefExoticComponent<DrawerHeaderProps & RefAttributes<HTMLDivElement>>;
|
|
33
34
|
export type DrawerBodyProps = HTMLAttributes<HTMLDivElement>;
|
|
34
35
|
export declare const DrawerBody: import('react').ForwardRefExoticComponent<DrawerBodyProps & RefAttributes<HTMLDivElement>>;
|
|
35
|
-
export
|
|
36
|
+
export interface DrawerFooterProps extends HTMLAttributes<HTMLDivElement> {
|
|
37
|
+
align?: OverlayFooterAlign;
|
|
38
|
+
}
|
|
36
39
|
export declare const DrawerFooter: import('react').ForwardRefExoticComponent<DrawerFooterProps & RefAttributes<HTMLDivElement>>;
|
|
37
40
|
export declare const Drawer: {
|
|
38
41
|
readonly Root: typeof DrawerRoot;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { cx as e, withStateClassName as t } from "../../internal/class-names.js";
|
|
2
3
|
import { useMessages as n } from "../../intl/provider.js";
|
|
3
4
|
import { forwardRef as r } from "react";
|
|
@@ -97,11 +98,12 @@ var d = r(function(e, t) {
|
|
|
97
98
|
ref: r,
|
|
98
99
|
className: e("lyds-drawer__body", t)
|
|
99
100
|
});
|
|
100
|
-
}), S = r(function({
|
|
101
|
+
}), S = r(function({ align: t = "stretch", className: n, ...r }, a) {
|
|
101
102
|
return /* @__PURE__ */ i("div", {
|
|
102
|
-
...
|
|
103
|
-
ref:
|
|
104
|
-
|
|
103
|
+
...r,
|
|
104
|
+
ref: a,
|
|
105
|
+
"data-align": t,
|
|
106
|
+
className: e("lyds-drawer__footer", n)
|
|
105
107
|
});
|
|
106
108
|
}), C = {
|
|
107
109
|
Root: l,
|
|
@@ -165,11 +167,12 @@ var E = r(function({ children: e, className: r, closeButton: o, closeLabel: c, c
|
|
|
165
167
|
ref: r,
|
|
166
168
|
className: e("lyds-drawer__body lyds-bottomSheet__body", t)
|
|
167
169
|
});
|
|
168
|
-
}), A = r(function({
|
|
170
|
+
}), A = r(function({ align: t = "stretch", className: n, ...r }, a) {
|
|
169
171
|
return /* @__PURE__ */ i("div", {
|
|
170
|
-
...
|
|
171
|
-
ref:
|
|
172
|
-
|
|
172
|
+
...r,
|
|
173
|
+
ref: a,
|
|
174
|
+
"data-align": t,
|
|
175
|
+
className: e("lyds-drawer__footer lyds-bottomSheet__footer", n)
|
|
173
176
|
});
|
|
174
177
|
}), j = {
|
|
175
178
|
Root: T,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.js","names":[],"sources":["../../../src/components/overlays/drawer.tsx"],"sourcesContent":["import {\n\tDrawer as BaseDrawer,\n\ttype DrawerCloseProps as BaseDrawerCloseProps,\n\ttype DrawerPopupProps as BaseDrawerPopupProps,\n\ttype DrawerBackdropProps,\n\ttype DrawerContentProps,\n\ttype DrawerDescriptionProps,\n\ttype DrawerPortalProps,\n\ttype DrawerRootProps,\n\ttype DrawerSwipeAreaProps,\n\ttype DrawerTitleProps,\n\ttype DrawerTriggerProps,\n\ttype DrawerViewportProps\n} from \"@base-ui/react/drawer\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { forwardRef, type HTMLAttributes, type JSX, type RefAttributes } from \"react\";\n\nimport { cx, withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\nexport type { DrawerRootChangeEventDetails } from \"@base-ui/react/drawer\";\n\nfunction CloseGlyph(): JSX.Element {\n\treturn <XIcon aria-hidden=\"true\" className=\"lyds-overlayClose__glyph\" weight=\"bold\" />;\n}\n\nexport function DrawerRoot<Payload = unknown>({ swipeDirection = \"right\", ...props }: DrawerRootProps<Payload>): JSX.Element {\n\treturn <BaseDrawer.Root {...props} swipeDirection={swipeDirection} />;\n}\n\nexport function DrawerTrigger<Payload = unknown>({ className, ...props }: DrawerTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BaseDrawer.Trigger {...props} className={withStateClassName(\"lyds-drawer__trigger\", className)} />;\n}\n\nexport const DrawerPortal = forwardRef<HTMLDivElement, DrawerPortalProps>(function DrawerPortal(props, ref) {\n\treturn <BaseDrawer.Portal {...props} ref={ref} />;\n});\n\nexport const DrawerBackdrop = forwardRef<HTMLDivElement, DrawerBackdropProps>(function DrawerBackdrop({ className, ...props }, ref) {\n\treturn <BaseDrawer.Backdrop {...props} ref={ref} className={withStateClassName(\"lyds-drawer__backdrop\", className)} />;\n});\n\nexport const DrawerViewport = forwardRef<HTMLDivElement, DrawerViewportProps>(function DrawerViewport({ className, ...props }, ref) {\n\treturn <BaseDrawer.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-drawer__viewport\", className)} />;\n});\n\nexport interface DrawerPopupProps extends BaseDrawerPopupProps {\n\t/** 內建關閉控制項的無障礙標籤。 */\n\tcloseLabel?: string;\n\t/** 傳給內建關閉控制項的屬性。 */\n\tcloseProps?: Omit<DrawerCloseProps, \"children\">;\n\t/** Renders the built-in corner close control. */\n\tcloseButton?: boolean;\n\t/**\n\t * @deprecated Pass `closeButton={false}` instead. Kept so existing call sites keep working.\n\t */\n\thasCustomClose?: boolean;\n}\n\nexport const DrawerPopup = forwardRef<HTMLDivElement, DrawerPopupProps>(function DrawerPopup({ children, className, closeButton, closeLabel, closeProps, hasCustomClose = false, ...props }, ref) {\n\tconst messages = useMessages();\n\tconst showCloseButton = closeButton ?? !hasCustomClose;\n\n\treturn (\n\t\t<BaseDrawer.Popup {...props} ref={ref} className={withStateClassName(\"lyds-drawer__popup\", className)}>\n\t\t\t{showCloseButton ? <DrawerClose {...closeProps} aria-label={closeLabel ?? messages.drawerClose} /> : null}\n\t\t\t{children}\n\t\t</BaseDrawer.Popup>\n\t);\n});\n\nexport const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(function DrawerContent({ className, ...props }, ref) {\n\treturn <BaseDrawer.Content {...props} ref={ref} className={withStateClassName(\"lyds-drawer__content\", className)} />;\n});\n\nexport const DrawerTitle = forwardRef<HTMLHeadingElement, DrawerTitleProps>(function DrawerTitle({ className, ...props }, ref) {\n\treturn <BaseDrawer.Title {...props} ref={ref} className={withStateClassName(\"lyds-drawer__title\", className)} />;\n});\n\nexport const DrawerDescription = forwardRef<HTMLParagraphElement, DrawerDescriptionProps>(function DrawerDescription({ className, ...props }, ref) {\n\treturn <BaseDrawer.Description {...props} ref={ref} className={withStateClassName(\"lyds-drawer__description\", className)} />;\n});\n\nexport interface DrawerCloseProps extends BaseDrawerCloseProps {\n\t/** 圖示控制項位於面板角落;動作控制項則參與內容排版。 */\n\tvariant?: \"icon\" | \"action\";\n}\n\nexport const DrawerClose = forwardRef<HTMLButtonElement, DrawerCloseProps>(function DrawerClose(\n\t{ \"aria-label\": ariaLabel, children, className, variant = children == null ? \"icon\" : \"action\", ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\n\treturn (\n\t\t<BaseDrawer.Close\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t\taria-label={ariaLabel ?? (children == null ? messages.drawerClose : undefined)}\n\t\t\tclassName={withStateClassName(variant === \"icon\" ? \"lyds-overlayClose\" : \"lyds-overlayCloseAction\", className)}\n\t\t>\n\t\t\t{children ?? <CloseGlyph />}\n\t\t</BaseDrawer.Close>\n\t);\n});\n\nexport const DrawerSwipeArea = forwardRef<HTMLDivElement, DrawerSwipeAreaProps>(function DrawerSwipeArea({ className, ...props }, ref) {\n\treturn <BaseDrawer.SwipeArea {...props} ref={ref} className={withStateClassName(\"lyds-drawer__swipeArea\", className)} />;\n});\n\nexport type DrawerHeaderProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DrawerHeader = forwardRef<HTMLDivElement, DrawerHeaderProps>(function DrawerHeader({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__header\", className)} />;\n});\n\nexport type DrawerBodyProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DrawerBody = forwardRef<HTMLDivElement, DrawerBodyProps>(function DrawerBody({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__body\", className)} />;\n});\n\nexport type DrawerFooterProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DrawerFooter = forwardRef<HTMLDivElement, DrawerFooterProps>(function DrawerFooter({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__footer\", className)} />;\n});\n\nexport const Drawer = {\n\tRoot: DrawerRoot,\n\tTrigger: DrawerTrigger,\n\tPortal: DrawerPortal,\n\tBackdrop: DrawerBackdrop,\n\tViewport: DrawerViewport,\n\tPopup: DrawerPopup,\n\tContent: DrawerContent,\n\tHeader: DrawerHeader,\n\tBody: DrawerBody,\n\tFooter: DrawerFooter,\n\tTitle: DrawerTitle,\n\tDescription: DrawerDescription,\n\tClose: DrawerClose,\n\tSwipeArea: DrawerSwipeArea,\n\tProvider: BaseDrawer.Provider,\n\tIndent: BaseDrawer.Indent,\n\tIndentBackground: BaseDrawer.IndentBackground,\n\tVirtualKeyboardProvider: BaseDrawer.VirtualKeyboardProvider,\n\tcreateHandle: BaseDrawer.createHandle,\n\tHandle: BaseDrawer.Handle\n} as const;\n\nexport type BottomSheetSnapPoint = number | `${number}rem`;\n\nexport interface BottomSheetRootProps<Payload = unknown> extends Omit<DrawerRootProps<Payload>, \"snapPoints\" | \"swipeDirection\"> {\n\t/** 響應式面板建議使用 0 至 1 的比例值或 rem 長度。 */\n\tsnapPoints?: BottomSheetSnapPoint[];\n\t/** 底部面板一律向下關閉。 */\n\tswipeDirection?: \"down\";\n}\n\nconst defaultBottomSheetSnapPoints: BottomSheetSnapPoint[] = [0.45, 0.92];\n\nexport function BottomSheetRoot<Payload = unknown>({ snapPoints = defaultBottomSheetSnapPoints, defaultSnapPoint, ...props }: BottomSheetRootProps<Payload>): JSX.Element {\n\tconst accessibleDefaultSnapPoint = snapPoints.at(-1) ?? null;\n\treturn <BaseDrawer.Root {...props} swipeDirection=\"down\" snapPoints={snapPoints} defaultSnapPoint={defaultSnapPoint ?? accessibleDefaultSnapPoint} />;\n}\n\nexport const BottomSheetPopup = forwardRef<HTMLDivElement, DrawerPopupProps>(function BottomSheetPopup(\n\t{ children, className, closeButton, closeLabel, closeProps, hasCustomClose = false, ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\tconst showCloseButton = closeButton ?? !hasCustomClose;\n\n\treturn (\n\t\t<BaseDrawer.Popup {...props} ref={ref} className={withStateClassName(\"lyds-drawer__popup lyds-bottomSheet__popup\", className)}>\n\t\t\t{showCloseButton ? <DrawerClose {...closeProps} aria-label={closeLabel ?? messages.bottomSheetClose} /> : null}\n\t\t\t{children}\n\t\t</BaseDrawer.Popup>\n\t);\n});\n\nexport type BottomSheetHandleProps = HTMLAttributes<HTMLDivElement>;\n\n/** 符合觸控尺寸的裝飾性操作提示;滑動行為仍由 Base UI 負責。 */\nexport const BottomSheetHandle = forwardRef<HTMLDivElement, BottomSheetHandleProps>(function BottomSheetHandle({ className, ...props }, ref) {\n\treturn (\n\t\t<div {...props} ref={ref} aria-hidden=\"true\" className={cx(\"lyds-bottomSheet__handle\", className)}>\n\t\t\t<span className=\"lyds-bottomSheet__handleBar\" />\n\t\t</div>\n\t);\n});\n\nexport const BottomSheetHeader = forwardRef<HTMLDivElement, DrawerHeaderProps>(function BottomSheetHeader({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__header lyds-bottomSheet__header\", className)} />;\n});\n\nexport const BottomSheetBody = forwardRef<HTMLDivElement, DrawerBodyProps>(function BottomSheetBody({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__body lyds-bottomSheet__body\", className)} />;\n});\n\nexport const BottomSheetFooter = forwardRef<HTMLDivElement, DrawerFooterProps>(function BottomSheetFooter({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__footer lyds-bottomSheet__footer\", className)} />;\n});\n\nexport const BottomSheet = {\n\tRoot: BottomSheetRoot,\n\tTrigger: DrawerTrigger,\n\tPortal: DrawerPortal,\n\tBackdrop: DrawerBackdrop,\n\tViewport: DrawerViewport,\n\tPopup: BottomSheetPopup,\n\tContent: DrawerContent,\n\tHandle: BottomSheetHandle,\n\tHeader: BottomSheetHeader,\n\tBody: BottomSheetBody,\n\tFooter: BottomSheetFooter,\n\tTitle: DrawerTitle,\n\tDescription: DrawerDescription,\n\tClose: DrawerClose,\n\tSwipeArea: DrawerSwipeArea,\n\tcreateHandle: BaseDrawer.createHandle,\n\tImperativeHandle: BaseDrawer.Handle\n} as const;\n"],"mappings":";;;;;;;AAqBA,SAA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F,UAAA,kBAAC,QAAD,EAAM,WAAU,8BAA+B,CAAA;CAC3C,CAAA;AAEP,CAAC,GAEY,IAAoB,EAA8C,SAA2B,EAAE,cAAW,GAAG,KAAS,GAAK;CACvI,OAAO,kBAAC,OAAD;EAAK,GAAI;EAAY;EAAK,WAAW,EAAG,gDAAgD,CAAS;CAAI,CAAA;AAC7G,CAAC,GAEY,IAAkB,EAA4C,SAAyB,EAAE,cAAW,GAAG,KAAS,GAAK;CACjI,OAAO,kBAAC,OAAD;EAAK,GAAI;EAAY;EAAK,WAAW,EAAG,4CAA4C,CAAS;CAAI,CAAA;AACzG,CAAC,GAEY,IAAoB,EAA8C,SAA2B,EAAE,cAAW,GAAG,KAAS,GAAK;CACvI,OAAO,kBAAC,OAAD;EAAK,GAAI;EAAY;EAAK,WAAW,EAAG,gDAAgD,CAAS;CAAI,CAAA;AAC7G,CAAC,GAEY,IAAc;CAC1B,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;CACV,UAAU;CACV,OAAO;CACP,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,OAAO;CACP,aAAa;CACb,OAAO;CACP,WAAW;CACX,cAAc,EAAW;CACzB,kBAAkB,EAAW;AAC9B"}
|
|
1
|
+
{"version":3,"file":"drawer.js","names":[],"sources":["../../../src/components/overlays/drawer.tsx"],"sourcesContent":["import {\n\tDrawer as BaseDrawer,\n\ttype DrawerCloseProps as BaseDrawerCloseProps,\n\ttype DrawerPopupProps as BaseDrawerPopupProps,\n\ttype DrawerBackdropProps,\n\ttype DrawerContentProps,\n\ttype DrawerDescriptionProps,\n\ttype DrawerPortalProps,\n\ttype DrawerRootProps,\n\ttype DrawerSwipeAreaProps,\n\ttype DrawerTitleProps,\n\ttype DrawerTriggerProps,\n\ttype DrawerViewportProps\n} from \"@base-ui/react/drawer\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { forwardRef, type HTMLAttributes, type JSX, type RefAttributes } from \"react\";\n\nimport { cx, withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\n\nimport type { OverlayFooterAlign } from \"./dialog\";\nexport type { DrawerRootChangeEventDetails } from \"@base-ui/react/drawer\";\n\nfunction CloseGlyph(): JSX.Element {\n\treturn <XIcon aria-hidden=\"true\" className=\"lyds-overlayClose__glyph\" weight=\"bold\" />;\n}\n\nexport function DrawerRoot<Payload = unknown>({ swipeDirection = \"right\", ...props }: DrawerRootProps<Payload>): JSX.Element {\n\treturn <BaseDrawer.Root {...props} swipeDirection={swipeDirection} />;\n}\n\nexport function DrawerTrigger<Payload = unknown>({ className, ...props }: DrawerTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BaseDrawer.Trigger {...props} className={withStateClassName(\"lyds-drawer__trigger\", className)} />;\n}\n\nexport const DrawerPortal = forwardRef<HTMLDivElement, DrawerPortalProps>(function DrawerPortal(props, ref) {\n\treturn <BaseDrawer.Portal {...props} ref={ref} />;\n});\n\nexport const DrawerBackdrop = forwardRef<HTMLDivElement, DrawerBackdropProps>(function DrawerBackdrop({ className, ...props }, ref) {\n\treturn <BaseDrawer.Backdrop {...props} ref={ref} className={withStateClassName(\"lyds-drawer__backdrop\", className)} />;\n});\n\nexport const DrawerViewport = forwardRef<HTMLDivElement, DrawerViewportProps>(function DrawerViewport({ className, ...props }, ref) {\n\treturn <BaseDrawer.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-drawer__viewport\", className)} />;\n});\n\nexport interface DrawerPopupProps extends BaseDrawerPopupProps {\n\t/** 內建關閉控制項的無障礙標籤。 */\n\tcloseLabel?: string;\n\t/** 傳給內建關閉控制項的屬性。 */\n\tcloseProps?: Omit<DrawerCloseProps, \"children\">;\n\t/** Renders the built-in corner close control. */\n\tcloseButton?: boolean;\n\t/**\n\t * @deprecated Pass `closeButton={false}` instead. Kept so existing call sites keep working.\n\t */\n\thasCustomClose?: boolean;\n}\n\nexport const DrawerPopup = forwardRef<HTMLDivElement, DrawerPopupProps>(function DrawerPopup({ children, className, closeButton, closeLabel, closeProps, hasCustomClose = false, ...props }, ref) {\n\tconst messages = useMessages();\n\tconst showCloseButton = closeButton ?? !hasCustomClose;\n\n\treturn (\n\t\t<BaseDrawer.Popup {...props} ref={ref} className={withStateClassName(\"lyds-drawer__popup\", className)}>\n\t\t\t{showCloseButton ? <DrawerClose {...closeProps} aria-label={closeLabel ?? messages.drawerClose} /> : null}\n\t\t\t{children}\n\t\t</BaseDrawer.Popup>\n\t);\n});\n\nexport const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(function DrawerContent({ className, ...props }, ref) {\n\treturn <BaseDrawer.Content {...props} ref={ref} className={withStateClassName(\"lyds-drawer__content\", className)} />;\n});\n\nexport const DrawerTitle = forwardRef<HTMLHeadingElement, DrawerTitleProps>(function DrawerTitle({ className, ...props }, ref) {\n\treturn <BaseDrawer.Title {...props} ref={ref} className={withStateClassName(\"lyds-drawer__title\", className)} />;\n});\n\nexport const DrawerDescription = forwardRef<HTMLParagraphElement, DrawerDescriptionProps>(function DrawerDescription({ className, ...props }, ref) {\n\treturn <BaseDrawer.Description {...props} ref={ref} className={withStateClassName(\"lyds-drawer__description\", className)} />;\n});\n\nexport interface DrawerCloseProps extends BaseDrawerCloseProps {\n\t/** 圖示控制項位於面板角落;動作控制項則參與內容排版。 */\n\tvariant?: \"icon\" | \"action\";\n}\n\nexport const DrawerClose = forwardRef<HTMLButtonElement, DrawerCloseProps>(function DrawerClose(\n\t{ \"aria-label\": ariaLabel, children, className, variant = children == null ? \"icon\" : \"action\", ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\n\treturn (\n\t\t<BaseDrawer.Close\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t\taria-label={ariaLabel ?? (children == null ? messages.drawerClose : undefined)}\n\t\t\tclassName={withStateClassName(variant === \"icon\" ? \"lyds-overlayClose\" : \"lyds-overlayCloseAction\", className)}\n\t\t>\n\t\t\t{children ?? <CloseGlyph />}\n\t\t</BaseDrawer.Close>\n\t);\n});\n\nexport const DrawerSwipeArea = forwardRef<HTMLDivElement, DrawerSwipeAreaProps>(function DrawerSwipeArea({ className, ...props }, ref) {\n\treturn <BaseDrawer.SwipeArea {...props} ref={ref} className={withStateClassName(\"lyds-drawer__swipeArea\", className)} />;\n});\n\nexport type DrawerHeaderProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DrawerHeader = forwardRef<HTMLDivElement, DrawerHeaderProps>(function DrawerHeader({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__header\", className)} />;\n});\n\nexport type DrawerBodyProps = HTMLAttributes<HTMLDivElement>;\n\nexport const DrawerBody = forwardRef<HTMLDivElement, DrawerBodyProps>(function DrawerBody({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__body\", className)} />;\n});\n\nexport interface DrawerFooterProps extends HTMLAttributes<HTMLDivElement> {\n\talign?: OverlayFooterAlign;\n}\n\nexport const DrawerFooter = forwardRef<HTMLDivElement, DrawerFooterProps>(function DrawerFooter({ align = \"stretch\", className, ...props }, ref) {\n\treturn <div {...props} ref={ref} data-align={align} className={cx(\"lyds-drawer__footer\", className)} />;\n});\n\nexport const Drawer = {\n\tRoot: DrawerRoot,\n\tTrigger: DrawerTrigger,\n\tPortal: DrawerPortal,\n\tBackdrop: DrawerBackdrop,\n\tViewport: DrawerViewport,\n\tPopup: DrawerPopup,\n\tContent: DrawerContent,\n\tHeader: DrawerHeader,\n\tBody: DrawerBody,\n\tFooter: DrawerFooter,\n\tTitle: DrawerTitle,\n\tDescription: DrawerDescription,\n\tClose: DrawerClose,\n\tSwipeArea: DrawerSwipeArea,\n\tProvider: BaseDrawer.Provider,\n\tIndent: BaseDrawer.Indent,\n\tIndentBackground: BaseDrawer.IndentBackground,\n\tVirtualKeyboardProvider: BaseDrawer.VirtualKeyboardProvider,\n\tcreateHandle: BaseDrawer.createHandle,\n\tHandle: BaseDrawer.Handle\n} as const;\n\nexport type BottomSheetSnapPoint = number | `${number}rem`;\n\nexport interface BottomSheetRootProps<Payload = unknown> extends Omit<DrawerRootProps<Payload>, \"snapPoints\" | \"swipeDirection\"> {\n\t/** 響應式面板建議使用 0 至 1 的比例值或 rem 長度。 */\n\tsnapPoints?: BottomSheetSnapPoint[];\n\t/** 底部面板一律向下關閉。 */\n\tswipeDirection?: \"down\";\n}\n\nconst defaultBottomSheetSnapPoints: BottomSheetSnapPoint[] = [0.45, 0.92];\n\nexport function BottomSheetRoot<Payload = unknown>({ snapPoints = defaultBottomSheetSnapPoints, defaultSnapPoint, ...props }: BottomSheetRootProps<Payload>): JSX.Element {\n\tconst accessibleDefaultSnapPoint = snapPoints.at(-1) ?? null;\n\treturn <BaseDrawer.Root {...props} swipeDirection=\"down\" snapPoints={snapPoints} defaultSnapPoint={defaultSnapPoint ?? accessibleDefaultSnapPoint} />;\n}\n\nexport const BottomSheetPopup = forwardRef<HTMLDivElement, DrawerPopupProps>(function BottomSheetPopup(\n\t{ children, className, closeButton, closeLabel, closeProps, hasCustomClose = false, ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\tconst showCloseButton = closeButton ?? !hasCustomClose;\n\n\treturn (\n\t\t<BaseDrawer.Popup {...props} ref={ref} className={withStateClassName(\"lyds-drawer__popup lyds-bottomSheet__popup\", className)}>\n\t\t\t{showCloseButton ? <DrawerClose {...closeProps} aria-label={closeLabel ?? messages.bottomSheetClose} /> : null}\n\t\t\t{children}\n\t\t</BaseDrawer.Popup>\n\t);\n});\n\nexport type BottomSheetHandleProps = HTMLAttributes<HTMLDivElement>;\n\n/** 符合觸控尺寸的裝飾性操作提示;滑動行為仍由 Base UI 負責。 */\nexport const BottomSheetHandle = forwardRef<HTMLDivElement, BottomSheetHandleProps>(function BottomSheetHandle({ className, ...props }, ref) {\n\treturn (\n\t\t<div {...props} ref={ref} aria-hidden=\"true\" className={cx(\"lyds-bottomSheet__handle\", className)}>\n\t\t\t<span className=\"lyds-bottomSheet__handleBar\" />\n\t\t</div>\n\t);\n});\n\nexport const BottomSheetHeader = forwardRef<HTMLDivElement, DrawerHeaderProps>(function BottomSheetHeader({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__header lyds-bottomSheet__header\", className)} />;\n});\n\nexport const BottomSheetBody = forwardRef<HTMLDivElement, DrawerBodyProps>(function BottomSheetBody({ className, ...props }, ref) {\n\treturn <div {...props} ref={ref} className={cx(\"lyds-drawer__body lyds-bottomSheet__body\", className)} />;\n});\n\nexport const BottomSheetFooter = forwardRef<HTMLDivElement, DrawerFooterProps>(function BottomSheetFooter({ align = \"stretch\", className, ...props }, ref) {\n\treturn <div {...props} ref={ref} data-align={align} className={cx(\"lyds-drawer__footer lyds-bottomSheet__footer\", className)} />;\n});\n\nexport const BottomSheet = {\n\tRoot: BottomSheetRoot,\n\tTrigger: DrawerTrigger,\n\tPortal: DrawerPortal,\n\tBackdrop: DrawerBackdrop,\n\tViewport: DrawerViewport,\n\tPopup: BottomSheetPopup,\n\tContent: DrawerContent,\n\tHandle: BottomSheetHandle,\n\tHeader: BottomSheetHeader,\n\tBody: BottomSheetBody,\n\tFooter: BottomSheetFooter,\n\tTitle: DrawerTitle,\n\tDescription: DrawerDescription,\n\tClose: DrawerClose,\n\tSwipeArea: DrawerSwipeArea,\n\tcreateHandle: BaseDrawer.createHandle,\n\tImperativeHandle: BaseDrawer.Handle\n} as const;\n"],"mappings":";;;;;;;;AAuBA,SAAS,IAA0B;CAClC,OAAO,kBAAC,GAAD;EAAO,eAAY;EAAO,WAAU;EAA2B,QAAO;CAAQ,CAAA;AACtF;AAEA,SAAgB,EAA8B,EAAE,oBAAiB,SAAS,GAAG,KAAgD;CAC5H,OAAO,kBAAC,EAAW,MAAZ;EAAiB,GAAI;EAAuB;CAAiB,CAAA;AACrE;AAEA,SAAgB,EAAiC,EAAE,cAAW,GAAG,KAAgF;CAChJ,OAAO,kBAAC,EAAW,SAAZ;EAAoB,GAAI;EAAO,WAAW,EAAm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BAAC,OAAD;EAAK,GAAI;EAAY;EAAK,WAAW,EAAG,4CAA4C,CAAS;CAAI,CAAA;AACzG,CAAC,GAEY,IAAoB,EAA8C,SAA2B,EAAE,WAAQ,WAAW,cAAW,GAAG,KAAS,GAAK;CAC1J,OAAO,kBAAC,OAAD;EAAK,GAAI;EAAY;EAAK,cAAY;EAAO,WAAW,EAAG,gDAAgD,CAAS;CAAI,CAAA;AAChI,CAAC,GAEY,IAAc;CAC1B,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;CACV,UAAU;CACV,OAAO;CACP,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,OAAO;CACP,aAAa;CACb,OAAO;CACP,WAAW;CACX,cAAc,EAAW;CACzB,kBAAkB,EAAW;AAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floating.js","names":[],"sources":["../../../src/components/overlays/floating.tsx"],"sourcesContent":["import {\n\tPopover as BasePopover,\n\ttype PopoverCloseProps as BasePopoverCloseProps,\n\ttype PopoverArrowProps,\n\ttype PopoverBackdropProps,\n\ttype PopoverDescriptionProps,\n\ttype PopoverPopupProps,\n\ttype PopoverPortalProps,\n\ttype PopoverPositionerProps,\n\ttype PopoverRootProps,\n\ttype PopoverTitleProps,\n\ttype PopoverTriggerProps,\n\ttype PopoverViewportProps\n} from \"@base-ui/react/popover\";\nimport {\n\tPreviewCard as BasePreviewCard,\n\ttype PreviewCardArrowProps,\n\ttype PreviewCardBackdropProps,\n\ttype PreviewCardPopupProps,\n\ttype PreviewCardPortalProps,\n\ttype PreviewCardPositionerProps,\n\ttype PreviewCardRootProps,\n\ttype PreviewCardTriggerProps,\n\ttype PreviewCardViewportProps\n} from \"@base-ui/react/preview-card\";\nimport {\n\tTooltip as BaseTooltip,\n\ttype TooltipPopupProps as BaseTooltipPopupProps,\n\ttype TooltipRootProps as BaseTooltipRootProps,\n\ttype TooltipArrowProps,\n\ttype TooltipPortalProps,\n\ttype TooltipPositionerProps,\n\ttype TooltipProviderProps,\n\ttype TooltipTriggerProps,\n\ttype TooltipViewportProps\n} from \"@base-ui/react/tooltip\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { createContext, forwardRef, useContext, useId, type JSX, type RefAttributes } from \"react\";\n\nimport { withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\nexport type { PopoverRootChangeEventDetails } from \"@base-ui/react/popover\";\nexport type { PreviewCardRootChangeEventDetails } from \"@base-ui/react/preview-card\";\nexport type { TooltipRootChangeEventDetails } from \"@base-ui/react/tooltip\";\n\nconst TooltipDescriptionContext = createContext<string | undefined>(undefined);\n\nfunction CloseGlyph(): JSX.Element {\n\treturn <XIcon aria-hidden=\"true\" className=\"lyds-overlayClose__glyph\" weight=\"bold\" />;\n}\n\nexport function TooltipProvider(props: TooltipProviderProps): JSX.Element {\n\treturn <BaseTooltip.Provider {...props} />;\n}\n\nexport interface TooltipRootProps<Payload = unknown> extends BaseTooltipRootProps<Payload> {\n\t/** 將觸發項目與 Tooltip 說明關聯的穩定 id。 */\n\tdescriptionId?: string;\n}\n\nexport type TooltipPopupProps = Omit<BaseTooltipPopupProps, \"id\" | \"role\">;\n\nexport function TooltipRoot<Payload = unknown>({ descriptionId, ...props }: TooltipRootProps<Payload>): JSX.Element {\n\tconst generatedId = useId();\n\treturn (\n\t\t<TooltipDescriptionContext.Provider value={descriptionId ?? `lyds-tooltip-${generatedId}`}>\n\t\t\t<BaseTooltip.Root {...props} />\n\t\t</TooltipDescriptionContext.Provider>\n\t);\n}\n\nexport function TooltipTrigger<Payload = unknown>({ className, ...props }: TooltipTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\tconst descriptionId = useContext(TooltipDescriptionContext);\n\tconst describedBy = [props[\"aria-describedby\"], descriptionId].filter(Boolean).join(\" \") || undefined;\n\treturn <BaseTooltip.Trigger {...props} aria-describedby={describedBy} className={withStateClassName(\"lyds-tooltip__trigger\", className)} />;\n}\n\nexport const TooltipPortal = forwardRef<HTMLDivElement, TooltipPortalProps>(function TooltipPortal(props, ref) {\n\treturn <BaseTooltip.Portal {...props} ref={ref} />;\n});\n\nexport const TooltipPositioner = forwardRef<HTMLDivElement, TooltipPositionerProps>(function TooltipPositioner({ className, sideOffset = 8, ...props }, ref) {\n\treturn <BaseTooltip.Positioner {...props} ref={ref} sideOffset={sideOffset} className={withStateClassName(\"lyds-tooltip__positioner\", className)} />;\n});\n\nexport const TooltipPopup = forwardRef<HTMLDivElement, TooltipPopupProps>(function TooltipPopup({ className, ...props }, ref) {\n\tconst descriptionId = useContext(TooltipDescriptionContext);\n\treturn <BaseTooltip.Popup {...props} ref={ref} id={descriptionId} role=\"tooltip\" className={withStateClassName(\"lyds-tooltip__popup\", className)} />;\n});\n\nexport const TooltipArrow = forwardRef<HTMLDivElement, TooltipArrowProps>(function TooltipArrow({ className, ...props }, ref) {\n\treturn <BaseTooltip.Arrow {...props} ref={ref} className={withStateClassName(\"lyds-tooltip__arrow\", className)} />;\n});\n\nexport const TooltipViewport = forwardRef<HTMLDivElement, TooltipViewportProps>(function TooltipViewport({ className, ...props }, ref) {\n\treturn <BaseTooltip.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-tooltip__viewport\", className)} />;\n});\n\nexport const Tooltip = {\n\tProvider: TooltipProvider,\n\tRoot: TooltipRoot,\n\tTrigger: TooltipTrigger,\n\tPortal: TooltipPortal,\n\tPositioner: TooltipPositioner,\n\tPopup: TooltipPopup,\n\tArrow: TooltipArrow,\n\tViewport: TooltipViewport,\n\tcreateHandle: BaseTooltip.createHandle,\n\tHandle: BaseTooltip.Handle\n} as const;\n\nexport function PopoverRoot<Payload = unknown>(props: PopoverRootProps<Payload>): JSX.Element {\n\treturn <BasePopover.Root {...props} />;\n}\n\nexport function PopoverTrigger<Payload = unknown>({ className, ...props }: PopoverTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BasePopover.Trigger {...props} className={withStateClassName(\"lyds-popover__trigger\", className)} />;\n}\n\nexport const PopoverPortal = forwardRef<HTMLDivElement, PopoverPortalProps>(function PopoverPortal(props, ref) {\n\treturn <BasePopover.Portal {...props} ref={ref} />;\n});\n\nexport const PopoverPositioner = forwardRef<HTMLDivElement, PopoverPositionerProps>(function PopoverPositioner({ className, sideOffset = 10, ...props }, ref) {\n\treturn <BasePopover.Positioner {...props} ref={ref} sideOffset={sideOffset} className={withStateClassName(\"lyds-popover__positioner\", className)} />;\n});\n\nexport const PopoverBackdrop = forwardRef<HTMLDivElement, PopoverBackdropProps>(function PopoverBackdrop({ className, ...props }, ref) {\n\treturn <BasePopover.Backdrop {...props} ref={ref} className={withStateClassName(\"lyds-popover__backdrop\", className)} />;\n});\n\nexport const PopoverPopup = forwardRef<HTMLDivElement, PopoverPopupProps>(function PopoverPopup({ className, ...props }, ref) {\n\treturn <BasePopover.Popup {...props} ref={ref} className={withStateClassName(\"lyds-popover__popup\", className)} />;\n});\n\nexport const PopoverArrow = forwardRef<HTMLDivElement, PopoverArrowProps>(function PopoverArrow({ className, ...props }, ref) {\n\treturn <BasePopover.Arrow {...props} ref={ref} className={withStateClassName(\"lyds-popover__arrow\", className)} />;\n});\n\nexport const PopoverTitle = forwardRef<HTMLHeadingElement, PopoverTitleProps>(function PopoverTitle({ className, ...props }, ref) {\n\treturn <BasePopover.Title {...props} ref={ref} className={withStateClassName(\"lyds-popover__title\", className)} />;\n});\n\nexport const PopoverDescription = forwardRef<HTMLParagraphElement, PopoverDescriptionProps>(function PopoverDescription({ className, ...props }, ref) {\n\treturn <BasePopover.Description {...props} ref={ref} className={withStateClassName(\"lyds-popover__description\", className)} />;\n});\n\nexport interface PopoverCloseProps extends BasePopoverCloseProps {\n\t/** 圖示控制項位於面板角落;動作控制項則參與內容排版。 */\n\tvariant?: \"icon\" | \"action\";\n}\n\nexport const PopoverClose = forwardRef<HTMLButtonElement, PopoverCloseProps>(function PopoverClose(\n\t{ \"aria-label\": ariaLabel, children, className, variant = children == null ? \"icon\" : \"action\", ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\n\treturn (\n\t\t<BasePopover.Close\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t\taria-label={ariaLabel ?? (children == null ? messages.popoverClose : undefined)}\n\t\t\tclassName={withStateClassName(variant === \"icon\" ? \"lyds-overlayClose\" : \"lyds-overlayCloseAction\", className)}\n\t\t>\n\t\t\t{children ?? <CloseGlyph />}\n\t\t</BasePopover.Close>\n\t);\n});\n\nexport const PopoverViewport = forwardRef<HTMLDivElement, PopoverViewportProps>(function PopoverViewport({ className, ...props }, ref) {\n\treturn <BasePopover.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-popover__viewport\", className)} />;\n});\n\nexport const Popover = {\n\tRoot: PopoverRoot,\n\tTrigger: PopoverTrigger,\n\tPortal: PopoverPortal,\n\tPositioner: PopoverPositioner,\n\tBackdrop: PopoverBackdrop,\n\tPopup: PopoverPopup,\n\tArrow: PopoverArrow,\n\tTitle: PopoverTitle,\n\tDescription: PopoverDescription,\n\tClose: PopoverClose,\n\tViewport: PopoverViewport,\n\tcreateHandle: BasePopover.createHandle,\n\tHandle: BasePopover.Handle\n} as const;\n\nexport function PreviewCardRoot<Payload = unknown>(props: PreviewCardRootProps<Payload>): JSX.Element {\n\treturn <BasePreviewCard.Root {...props} />;\n}\n\nexport function PreviewCardTrigger<Payload = unknown>({ className, ...props }: PreviewCardTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BasePreviewCard.Trigger {...props} className={withStateClassName(\"lyds-previewCard__trigger\", className)} />;\n}\n\nexport const PreviewCardPortal = forwardRef<HTMLDivElement, PreviewCardPortalProps>(function PreviewCardPortal(props, ref) {\n\treturn <BasePreviewCard.Portal {...props} ref={ref} />;\n});\n\nexport const PreviewCardPositioner = forwardRef<HTMLDivElement, PreviewCardPositionerProps>(function PreviewCardPositioner({ className, sideOffset = 10, ...props }, ref) {\n\treturn <BasePreviewCard.Positioner {...props} ref={ref} sideOffset={sideOffset} className={withStateClassName(\"lyds-previewCard__positioner\", className)} />;\n});\n\n/** PreviewCard 僅補充觸發項目的資訊;必要內容仍應顯示於頁面中。 */\nexport const PreviewCardPopup = forwardRef<HTMLDivElement, PreviewCardPopupProps>(function PreviewCardPopup({ className, ...props }, ref) {\n\treturn <BasePreviewCard.Popup {...props} ref={ref} className={withStateClassName(\"lyds-previewCard__popup\", className)} />;\n});\n\nexport const PreviewCardArrow = forwardRef<HTMLDivElement, PreviewCardArrowProps>(function PreviewCardArrow({ className, ...props }, ref) {\n\treturn <BasePreviewCard.Arrow {...props} ref={ref} className={withStateClassName(\"lyds-previewCard__arrow\", className)} />;\n});\n\nexport const PreviewCardBackdrop = forwardRef<HTMLDivElement, PreviewCardBackdropProps>(function PreviewCardBackdrop({ className, ...props }, ref) {\n\treturn <BasePreviewCard.Backdrop {...props} ref={ref} className={withStateClassName(\"lyds-previewCard__backdrop\", className)} />;\n});\n\nexport const PreviewCardViewport = forwardRef<HTMLDivElement, PreviewCardViewportProps>(function PreviewCardViewport({ className, ...props }, ref) {\n\treturn <BasePreviewCard.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-previewCard__viewport\", className)} />;\n});\n\nexport const PreviewCard = {\n\tRoot: PreviewCardRoot,\n\tTrigger: PreviewCardTrigger,\n\tPortal: PreviewCardPortal,\n\tPositioner: PreviewCardPositioner,\n\tPopup: PreviewCardPopup,\n\tArrow: PreviewCardArrow,\n\tBackdrop: PreviewCardBackdrop,\n\tViewport: PreviewCardViewport,\n\tcreateHandle: BasePreviewCard.createHandle,\n\tHandle: BasePreviewCard.Handle\n} as const;\n"],"mappings":";;;;;;;;;AA6CA,IAAM,IAA4B,EAAkC,KAAA,CAAS;AAE7E,SAAS,IAA0B;CAClC,OAAO,kBAAC,GAAD;EAAO,eAAY;EAAO,WAAU;EAA2B,QAAO;CAAQ,CAAA;AACtF;AAEA,SAAgB,EAAgB,GAA0C;CACzE,OAAO,kBAAC,EAAY,UAAb,EAAs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AAU;CACV,UAAU;CACV,cAAc,EAAgB;CAC9B,QAAQ,EAAgB;AACzB"}
|
|
1
|
+
{"version":3,"file":"floating.js","names":[],"sources":["../../../src/components/overlays/floating.tsx"],"sourcesContent":["import {\n\tPopover as BasePopover,\n\ttype PopoverCloseProps as BasePopoverCloseProps,\n\ttype PopoverArrowProps,\n\ttype PopoverBackdropProps,\n\ttype PopoverDescriptionProps,\n\ttype PopoverPopupProps,\n\ttype PopoverPortalProps,\n\ttype PopoverPositionerProps,\n\ttype PopoverRootProps,\n\ttype PopoverTitleProps,\n\ttype PopoverTriggerProps,\n\ttype PopoverViewportProps\n} from \"@base-ui/react/popover\";\nimport {\n\tPreviewCard as BasePreviewCard,\n\ttype PreviewCardArrowProps,\n\ttype PreviewCardBackdropProps,\n\ttype PreviewCardPopupProps,\n\ttype PreviewCardPortalProps,\n\ttype PreviewCardPositionerProps,\n\ttype PreviewCardRootProps,\n\ttype PreviewCardTriggerProps,\n\ttype PreviewCardViewportProps\n} from \"@base-ui/react/preview-card\";\nimport {\n\tTooltip as BaseTooltip,\n\ttype TooltipPopupProps as BaseTooltipPopupProps,\n\ttype TooltipRootProps as BaseTooltipRootProps,\n\ttype TooltipArrowProps,\n\ttype TooltipPortalProps,\n\ttype TooltipPositionerProps,\n\ttype TooltipProviderProps,\n\ttype TooltipTriggerProps,\n\ttype TooltipViewportProps\n} from \"@base-ui/react/tooltip\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { createContext, forwardRef, useContext, useId, type JSX, type RefAttributes } from \"react\";\n\nimport { withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\nexport type { PopoverRootChangeEventDetails } from \"@base-ui/react/popover\";\nexport type { PreviewCardRootChangeEventDetails } from \"@base-ui/react/preview-card\";\nexport type { TooltipRootChangeEventDetails } from \"@base-ui/react/tooltip\";\n\nconst TooltipDescriptionContext = createContext<string | undefined>(undefined);\n\nfunction CloseGlyph(): JSX.Element {\n\treturn <XIcon aria-hidden=\"true\" className=\"lyds-overlayClose__glyph\" weight=\"bold\" />;\n}\n\nexport function TooltipProvider(props: TooltipProviderProps): JSX.Element {\n\treturn <BaseTooltip.Provider {...props} />;\n}\n\nexport interface TooltipRootProps<Payload = unknown> extends BaseTooltipRootProps<Payload> {\n\t/** 將觸發項目與 Tooltip 說明關聯的穩定 id。 */\n\tdescriptionId?: string;\n}\n\nexport type TooltipPopupProps = Omit<BaseTooltipPopupProps, \"id\" | \"role\">;\n\nexport function TooltipRoot<Payload = unknown>({ descriptionId, ...props }: TooltipRootProps<Payload>): JSX.Element {\n\tconst generatedId = useId();\n\treturn (\n\t\t<TooltipDescriptionContext.Provider value={descriptionId ?? `lyds-tooltip-${generatedId}`}>\n\t\t\t<BaseTooltip.Root {...props} />\n\t\t</TooltipDescriptionContext.Provider>\n\t);\n}\n\nexport function TooltipTrigger<Payload = unknown>({ className, ...props }: TooltipTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\tconst descriptionId = useContext(TooltipDescriptionContext);\n\tconst describedBy = [props[\"aria-describedby\"], descriptionId].filter(Boolean).join(\" \") || undefined;\n\treturn <BaseTooltip.Trigger {...props} aria-describedby={describedBy} className={withStateClassName(\"lyds-tooltip__trigger\", className)} />;\n}\n\nexport const TooltipPortal = forwardRef<HTMLDivElement, TooltipPortalProps>(function TooltipPortal(props, ref) {\n\treturn <BaseTooltip.Portal {...props} ref={ref} />;\n});\n\nexport const TooltipPositioner = forwardRef<HTMLDivElement, TooltipPositionerProps>(function TooltipPositioner({ className, sideOffset = 8, ...props }, ref) {\n\treturn <BaseTooltip.Positioner {...props} ref={ref} sideOffset={sideOffset} className={withStateClassName(\"lyds-tooltip__positioner\", className)} />;\n});\n\nexport const TooltipPopup = forwardRef<HTMLDivElement, TooltipPopupProps>(function TooltipPopup({ className, ...props }, ref) {\n\tconst descriptionId = useContext(TooltipDescriptionContext);\n\treturn <BaseTooltip.Popup {...props} ref={ref} id={descriptionId} role=\"tooltip\" className={withStateClassName(\"lyds-tooltip__popup\", className)} />;\n});\n\nexport const TooltipArrow = forwardRef<HTMLDivElement, TooltipArrowProps>(function TooltipArrow({ className, ...props }, ref) {\n\treturn <BaseTooltip.Arrow {...props} ref={ref} className={withStateClassName(\"lyds-tooltip__arrow\", className)} />;\n});\n\nexport const TooltipViewport = forwardRef<HTMLDivElement, TooltipViewportProps>(function TooltipViewport({ className, ...props }, ref) {\n\treturn <BaseTooltip.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-tooltip__viewport\", className)} />;\n});\n\nexport const Tooltip = {\n\tProvider: TooltipProvider,\n\tRoot: TooltipRoot,\n\tTrigger: TooltipTrigger,\n\tPortal: TooltipPortal,\n\tPositioner: TooltipPositioner,\n\tPopup: TooltipPopup,\n\tArrow: TooltipArrow,\n\tViewport: TooltipViewport,\n\tcreateHandle: BaseTooltip.createHandle,\n\tHandle: BaseTooltip.Handle\n} as const;\n\nexport function PopoverRoot<Payload = unknown>(props: PopoverRootProps<Payload>): JSX.Element {\n\treturn <BasePopover.Root {...props} />;\n}\n\nexport function PopoverTrigger<Payload = unknown>({ className, ...props }: PopoverTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BasePopover.Trigger {...props} className={withStateClassName(\"lyds-popover__trigger\", className)} />;\n}\n\nexport const PopoverPortal = forwardRef<HTMLDivElement, PopoverPortalProps>(function PopoverPortal(props, ref) {\n\treturn <BasePopover.Portal {...props} ref={ref} />;\n});\n\nexport const PopoverPositioner = forwardRef<HTMLDivElement, PopoverPositionerProps>(function PopoverPositioner({ className, sideOffset = 10, ...props }, ref) {\n\treturn <BasePopover.Positioner {...props} ref={ref} sideOffset={sideOffset} className={withStateClassName(\"lyds-popover__positioner\", className)} />;\n});\n\nexport const PopoverBackdrop = forwardRef<HTMLDivElement, PopoverBackdropProps>(function PopoverBackdrop({ className, ...props }, ref) {\n\treturn <BasePopover.Backdrop {...props} ref={ref} className={withStateClassName(\"lyds-popover__backdrop\", className)} />;\n});\n\nexport const PopoverPopup = forwardRef<HTMLDivElement, PopoverPopupProps>(function PopoverPopup({ className, ...props }, ref) {\n\treturn <BasePopover.Popup {...props} ref={ref} className={withStateClassName(\"lyds-popover__popup\", className)} />;\n});\n\nexport const PopoverArrow = forwardRef<HTMLDivElement, PopoverArrowProps>(function PopoverArrow({ className, ...props }, ref) {\n\treturn <BasePopover.Arrow {...props} ref={ref} className={withStateClassName(\"lyds-popover__arrow\", className)} />;\n});\n\nexport const PopoverTitle = forwardRef<HTMLHeadingElement, PopoverTitleProps>(function PopoverTitle({ className, ...props }, ref) {\n\treturn <BasePopover.Title {...props} ref={ref} className={withStateClassName(\"lyds-popover__title\", className)} />;\n});\n\nexport const PopoverDescription = forwardRef<HTMLParagraphElement, PopoverDescriptionProps>(function PopoverDescription({ className, ...props }, ref) {\n\treturn <BasePopover.Description {...props} ref={ref} className={withStateClassName(\"lyds-popover__description\", className)} />;\n});\n\nexport interface PopoverCloseProps extends BasePopoverCloseProps {\n\t/** 圖示控制項位於面板角落;動作控制項則參與內容排版。 */\n\tvariant?: \"icon\" | \"action\";\n}\n\nexport const PopoverClose = forwardRef<HTMLButtonElement, PopoverCloseProps>(function PopoverClose(\n\t{ \"aria-label\": ariaLabel, children, className, variant = children == null ? \"icon\" : \"action\", ...props },\n\tref\n) {\n\tconst messages = useMessages();\n\n\treturn (\n\t\t<BasePopover.Close\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t\taria-label={ariaLabel ?? (children == null ? messages.popoverClose : undefined)}\n\t\t\tclassName={withStateClassName(variant === \"icon\" ? \"lyds-overlayClose\" : \"lyds-overlayCloseAction\", className)}\n\t\t>\n\t\t\t{children ?? <CloseGlyph />}\n\t\t</BasePopover.Close>\n\t);\n});\n\nexport const PopoverViewport = forwardRef<HTMLDivElement, PopoverViewportProps>(function PopoverViewport({ className, ...props }, ref) {\n\treturn <BasePopover.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-popover__viewport\", className)} />;\n});\n\nexport const Popover = {\n\tRoot: PopoverRoot,\n\tTrigger: PopoverTrigger,\n\tPortal: PopoverPortal,\n\tPositioner: PopoverPositioner,\n\tBackdrop: PopoverBackdrop,\n\tPopup: PopoverPopup,\n\tArrow: PopoverArrow,\n\tTitle: PopoverTitle,\n\tDescription: PopoverDescription,\n\tClose: PopoverClose,\n\tViewport: PopoverViewport,\n\tcreateHandle: BasePopover.createHandle,\n\tHandle: BasePopover.Handle\n} as const;\n\nexport function PreviewCardRoot<Payload = unknown>(props: PreviewCardRootProps<Payload>): JSX.Element {\n\treturn <BasePreviewCard.Root {...props} />;\n}\n\nexport function PreviewCardTrigger<Payload = unknown>({ className, ...props }: PreviewCardTriggerProps<Payload> & RefAttributes<HTMLElement>): JSX.Element {\n\treturn <BasePreviewCard.Trigger {...props} className={withStateClassName(\"lyds-previewCard__trigger\", className)} />;\n}\n\nexport const PreviewCardPortal = forwardRef<HTMLDivElement, PreviewCardPortalProps>(function PreviewCardPortal(props, ref) {\n\treturn <BasePreviewCard.Portal {...props} ref={ref} />;\n});\n\nexport const PreviewCardPositioner = forwardRef<HTMLDivElement, PreviewCardPositionerProps>(function PreviewCardPositioner({ className, sideOffset = 10, ...props }, ref) {\n\treturn <BasePreviewCard.Positioner {...props} ref={ref} sideOffset={sideOffset} className={withStateClassName(\"lyds-previewCard__positioner\", className)} />;\n});\n\n/** PreviewCard 僅補充觸發項目的資訊;必要內容仍應顯示於頁面中。 */\nexport const PreviewCardPopup = forwardRef<HTMLDivElement, PreviewCardPopupProps>(function PreviewCardPopup({ className, ...props }, ref) {\n\treturn <BasePreviewCard.Popup {...props} ref={ref} className={withStateClassName(\"lyds-previewCard__popup\", className)} />;\n});\n\nexport const PreviewCardArrow = forwardRef<HTMLDivElement, PreviewCardArrowProps>(function PreviewCardArrow({ className, ...props }, ref) {\n\treturn <BasePreviewCard.Arrow {...props} ref={ref} className={withStateClassName(\"lyds-previewCard__arrow\", className)} />;\n});\n\nexport const PreviewCardBackdrop = forwardRef<HTMLDivElement, PreviewCardBackdropProps>(function PreviewCardBackdrop({ className, ...props }, ref) {\n\treturn <BasePreviewCard.Backdrop {...props} ref={ref} className={withStateClassName(\"lyds-previewCard__backdrop\", className)} />;\n});\n\nexport const PreviewCardViewport = forwardRef<HTMLDivElement, PreviewCardViewportProps>(function PreviewCardViewport({ className, ...props }, ref) {\n\treturn <BasePreviewCard.Viewport {...props} ref={ref} className={withStateClassName(\"lyds-previewCard__viewport\", className)} />;\n});\n\nexport const PreviewCard = {\n\tRoot: PreviewCardRoot,\n\tTrigger: PreviewCardTrigger,\n\tPortal: PreviewCardPortal,\n\tPositioner: PreviewCardPositioner,\n\tPopup: PreviewCardPopup,\n\tArrow: PreviewCardArrow,\n\tBackdrop: PreviewCardBackdrop,\n\tViewport: PreviewCardViewport,\n\tcreateHandle: BasePreviewCard.createHandle,\n\tHandle: BasePreviewCard.Handle\n} as const;\n"],"mappings":";;;;;;;;;;AA6CA,IAAM,IAA4B,EAAkC,KAAA,CAAS;AAE7E,SAAS,IAA0B;CAClC,OAAO,kBAAC,GAAD;EAAO,eAAY;EAAO,WAAU;EAA2B,QAAO;CAAQ,CAAA;AACtF;AAEA,SAAgB,EAAgB,GAA0C;CACzE,OAAO,kBAAC,EAAY,UAAb,EAAsB,GAAI,EAAQ,CAAA;AAC1C;AASA,SAAgB,EAA+B,EAAE,kBAAe,GAAG,KAAiD;CACnH,IAAM,IAAc,EAAM;CAC1B,OACC,kBAAC,EAA0B,UAA3B;EAAoC,OAAO,KAAiB,gBAAgB;EAC3E,UAAA,kBAAC,EAAY,MAAb,EAAkB,GAAI,EAAQ,CAAA;CACK,CAAA;AAEtC;AAEA,SAAgB,EAAkC,EAAE,cAAW,GAAG,KAAiF;CAClJ,IAAM,IAAgB,EAAW,CAAyB,GACpD,IAAc,CAAC,EAAM,qBAAqB,CAAa,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;CAC5F,OAAO,kBAAC,EAAY,SAAb;EAAqB,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5J,CAAC,GAGY,IAAmB,EAAkD,SAA0B,EAAE,cAAW,GAAG,KAAS,GAAK;CACzI,OAAO,kBAAC,EAAgB,OAAjB;EAAuB,GAAI;EAAY;EAAK,WAAW,EAAmB,2BAA2B,CAAS;CAAI,CAAA;AAC1H,CAAC,GAEY,IAAmB,EAAkD,SAA0B,EAAE,cAAW,GAAG,KAAS,GAAK;CACzI,OAAO,kBAAC,EAAgB,OAAjB;EAAuB,GAAI;EAAY;EAAK,WAAW,EAAmB,2BAA2B,CAAS;CAAI,CAAA;AAC1H,CAAC,GAEY,IAAsB,EAAqD,SAA6B,EAAE,cAAW,GAAG,KAAS,GAAK;CAClJ,OAAO,kBAAC,EAAgB,UAAjB;EAA0B,GAAI;EAAY;EAAK,WAAW,EAAmB,8BAA8B,CAAS;CAAI,CAAA;AAChI,CAAC,GAEY,IAAsB,EAAqD,SAA6B,EAAE,cAAW,GAAG,KAAS,GAAK;CAClJ,OAAO,kBAAC,EAAgB,UAAjB;EAA0B,GAAI;EAAY;EAAK,WAAW,EAAmB,8BAA8B,CAAS;CAAI,CAAA;AAChI,CAAC,GAEY,IAAc;CAC1B,MAAM;CACN,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,OAAO;CACP,OAAO;CACP,UAAU;CACV,UAAU;CACV,cAAc,EAAgB;CAC9B,QAAQ,EAAgB;AACzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AlertDialog, AlertDialogActions, AlertDialogClose, AlertDialogPopup, AlertDialogRoot, AlertDialogTrigger, Dialog, DialogBackdrop, DialogBody, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogPortal, DialogRoot, DialogTitle, DialogTrigger, DialogViewport, Modal, type AlertDialogActionsProps, type AlertDialogPopupProps, type AlertDialogRootChangeEventDetails, type DialogBodyProps, type DialogCloseProps, type DialogFooterProps, type DialogHeaderProps, type DialogPopupProps, type DialogRootChangeEventDetails } from './dialog.js';
|
|
1
|
+
export { AlertDialog, AlertDialogActions, AlertDialogClose, AlertDialogPopup, AlertDialogRoot, AlertDialogTrigger, Dialog, DialogBackdrop, DialogBody, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogPortal, DialogRoot, DialogTitle, DialogTrigger, DialogViewport, Modal, type AlertDialogActionsProps, type AlertDialogPopupProps, type AlertDialogRootChangeEventDetails, type DialogBodyProps, type DialogCloseProps, type DialogFooterProps, type DialogHeaderProps, type DialogPopupProps, type DialogRootChangeEventDetails, type OverlayFooterAlign } from './dialog.js';
|
|
2
2
|
export { Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionRoot, AccordionTrigger, Collapsible, CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger, Tabs, TabsIndicator, TabsList, TabsPanel, TabsRoot, TabsTab, type AccordionRootChangeEventDetails, type CollapsibleRootChangeEventDetails, type TabsRootChangeEventDetails } from './disclosure.js';
|
|
3
3
|
export { BottomSheet, BottomSheetBody, BottomSheetFooter, BottomSheetHandle, BottomSheetHeader, BottomSheetPopup, BottomSheetRoot, Drawer, DrawerBackdrop, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerPopup, DrawerPortal, DrawerRoot, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerViewport, type BottomSheetHandleProps, type BottomSheetRootProps, type BottomSheetSnapPoint, type DrawerBodyProps, type DrawerCloseProps, type DrawerFooterProps, type DrawerHeaderProps, type DrawerPopupProps, type DrawerRootChangeEventDetails } from './drawer.js';
|
|
4
4
|
export { Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverDescription, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverRoot, PopoverTitle, PopoverTrigger, PopoverViewport, PreviewCard, PreviewCardArrow, PreviewCardBackdrop, PreviewCardPopup, PreviewCardPortal, PreviewCardPositioner, PreviewCardRoot, PreviewCardTrigger, PreviewCardViewport, Tooltip, TooltipArrow, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipProvider, TooltipRoot, TooltipTrigger, TooltipViewport, type PopoverCloseProps, type PopoverRootChangeEventDetails, type PreviewCardRootChangeEventDetails, type TooltipPopupProps, type TooltipRootChangeEventDetails, type TooltipRootProps } from './floating.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.js","names":[],"sources":["../../../src/components/selection/combobox.tsx"],"sourcesContent":["import { Autocomplete as BaseAutocomplete, type AutocompleteInputGroupProps, type AutocompleteItemProps, type AutocompleteRootProps } from \"@base-ui/react/autocomplete\";\nimport {\n\tCombobox as BaseCombobox,\n\ttype ComboboxClearProps,\n\ttype ComboboxEmptyProps,\n\ttype ComboboxInputGroupProps,\n\ttype ComboboxInputProps,\n\ttype ComboboxItemIndicatorProps,\n\ttype ComboboxItemProps,\n\ttype ComboboxListProps,\n\ttype ComboboxPopupProps,\n\ttype ComboboxPositionerProps,\n\ttype ComboboxRootProps,\n\ttype ComboboxTriggerProps\n} from \"@base-ui/react/combobox\";\nimport { CaretDownIcon } from \"@phosphor-icons/react/dist/csr/CaretDown\";\nimport { CheckIcon } from \"@phosphor-icons/react/dist/csr/Check\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { forwardRef, useMemo, type Key, type ReactNode } from \"react\";\n\nimport { withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\n\nexport const ComboboxInputGroup = forwardRef<HTMLDivElement, ComboboxInputGroupProps>(function ComboboxInputGroup({ className, ...props }, ref) {\n\treturn <BaseCombobox.InputGroup {...props} className={withStateClassName(\"lyds-combobox__input-group\", className)} ref={ref} />;\n});\n\nexport const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(function ComboboxInput({ className, ...props }, ref) {\n\treturn <BaseCombobox.Input {...props} className={withStateClassName(\"lyds-combobox__input\", className)} ref={ref} />;\n});\n\nexport const ComboboxTrigger = forwardRef<HTMLButtonElement, ComboboxTriggerProps>(function ComboboxTrigger({ className, ...props }, ref) {\n\treturn <BaseCombobox.Trigger {...props} className={withStateClassName(\"lyds-combobox__trigger\", className)} ref={ref} />;\n});\n\nexport const ComboboxClear = forwardRef<HTMLButtonElement, ComboboxClearProps>(function ComboboxClear({ className, ...props }, ref) {\n\treturn <BaseCombobox.Clear {...props} className={withStateClassName(\"lyds-combobox__clear\", className)} ref={ref} />;\n});\n\nexport const ComboboxPositioner = forwardRef<HTMLDivElement, ComboboxPositionerProps>(function ComboboxPositioner({ className, ...props }, ref) {\n\treturn <BaseCombobox.Positioner {...props} className={withStateClassName(\"lyds-listbox__positioner\", className)} ref={ref} />;\n});\n\nexport const ComboboxPopup = forwardRef<HTMLDivElement, ComboboxPopupProps>(function ComboboxPopup({ className, ...props }, ref) {\n\treturn <BaseCombobox.Popup {...props} className={withStateClassName(\"lyds-listbox__popup\", className)} ref={ref} />;\n});\n\nexport const ComboboxList = forwardRef<HTMLDivElement, ComboboxListProps>(function ComboboxList({ className, ...props }, ref) {\n\treturn <BaseCombobox.List {...props} className={withStateClassName(\"lyds-listbox__list\", className)} ref={ref} />;\n});\n\nexport const ComboboxItem = forwardRef<HTMLDivElement, ComboboxItemProps>(function ComboboxItem({ className, ...props }, ref) {\n\treturn <BaseCombobox.Item {...props} className={withStateClassName(\"lyds-listbox__option\", className)} ref={ref} />;\n});\n\nexport const ComboboxItemIndicator = forwardRef<HTMLSpanElement, ComboboxItemIndicatorProps>(function ComboboxItemIndicator({ className, ...props }, ref) {\n\treturn <BaseCombobox.ItemIndicator {...props} className={withStateClassName(\"lyds-listbox__option-indicator\", className)} ref={ref} />;\n});\n\nexport const ComboboxEmpty = forwardRef<HTMLDivElement, ComboboxEmptyProps>(function ComboboxEmpty({ className, ...props }, ref) {\n\treturn <BaseCombobox.Empty {...props} className={withStateClassName(\"lyds-listbox__empty\", className)} ref={ref} />;\n});\n\nexport interface ComboboxOption<Value> {\n\tdescription?: ReactNode;\n\tdisabled?: boolean;\n\tkey?: Key;\n\tlabel: ReactNode;\n\ttextValue?: string;\n\tvalue: Value;\n}\n\ninterface IndexedOption<Option> {\n\toption: Option;\n\tsourceIndex: number;\n}\n\nfunction createOptionIndex<Value, Option extends { value: Value }>(options: readonly Option[]) {\n\tconst values: Value[] = [];\n\tconst lookup = new Map<Value, IndexedOption<Option>>();\n\tlet negativeZero: IndexedOption<Option> | undefined;\n\tlet positiveZero: IndexedOption<Option> | undefined;\n\n\toptions.forEach((option, sourceIndex) => {\n\t\tconst value = option.value;\n\t\tconst indexed = { option, sourceIndex };\n\t\tvalues.push(value);\n\n\t\tif (typeof value === \"number\" && value === 0) {\n\t\t\tif (Object.is(value, -0)) negativeZero ??= indexed;\n\t\t\telse positiveZero ??= indexed;\n\t\t\treturn;\n\t\t}\n\n\t\tif (!lookup.has(value)) lookup.set(value, indexed);\n\t});\n\n\treturn {\n\t\tvalues,\n\t\tget(value: Value) {\n\t\t\tif (typeof value === \"number\" && value === 0) {\n\t\t\t\treturn Object.is(value, -0) ? negativeZero : positiveZero;\n\t\t\t}\n\t\t\treturn lookup.get(value);\n\t\t}\n\t};\n}\n\nexport interface ComboboxProps<Value> extends Omit<ComboboxRootProps<Value, false>, \"children\" | \"items\" | \"multiple\"> {\n\t\"aria-describedby\"?: string;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n\tclearLabel?: string;\n\temptyMessage?: ReactNode;\n\tinputProps?: Omit<ComboboxInputProps, \"className\" | \"placeholder\">;\n\tinvalid?: boolean;\n\toptions: readonly ComboboxOption<Value>[];\n\tplaceholder?: string;\n\tpopupProps?: ComboboxPopupProps;\n\tpositionerProps?: ComboboxPositionerProps;\n\ttriggerLabel?: string;\n}\n\nfunction ComboboxComponent<Value>({\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\tclassName,\n\tclearLabel,\n\temptyMessage,\n\tinputProps,\n\tinvalid = false,\n\titemToStringLabel,\n\toptions,\n\tplaceholder,\n\tpopupProps,\n\tpositionerProps,\n\ttriggerLabel,\n\t...rootProps\n}: ComboboxProps<Value>) {\n\tconst messages = useMessages();\n\tconst optionIndex = useMemo(() => createOptionIndex<Value, ComboboxOption<Value>>(options), [options]);\n\tconst stringify = useMemo(\n\t\t() =>\n\t\t\titemToStringLabel ??\n\t\t\t((itemValue: Value) => {\n\t\t\t\tconst option = optionIndex.get(itemValue)?.option;\n\t\t\t\treturn option?.textValue ?? (typeof option?.label === \"string\" ? option.label : String(itemValue));\n\t\t\t}),\n\t\t[itemToStringLabel, optionIndex]\n\t);\n\n\treturn (\n\t\t<BaseCombobox.Root {...rootProps} itemToStringLabel={stringify} items={optionIndex.values}>\n\t\t\t<ComboboxInputGroup className={className}>\n\t\t\t\t<ComboboxInput\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\taria-describedby={ariaDescribedby ?? inputProps?.[\"aria-describedby\"]}\n\t\t\t\t\taria-invalid={invalid || inputProps?.[\"aria-invalid\"] || undefined}\n\t\t\t\t\taria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledby ?? inputProps?.[\"aria-labelledby\"]}\n\t\t\t\t\tautoComplete={inputProps?.autoComplete ?? \"off\"}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t\t<ComboboxClear aria-label={clearLabel ?? messages.comboboxClear}>\n\t\t\t\t\t<XIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxClear>\n\t\t\t\t<ComboboxTrigger aria-label={triggerLabel ?? messages.comboboxTrigger}>\n\t\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxTrigger>\n\t\t\t</ComboboxInputGroup>\n\t\t\t<BaseCombobox.Portal>\n\t\t\t\t<ComboboxPositioner {...positionerProps}>\n\t\t\t\t\t<ComboboxPopup {...popupProps}>\n\t\t\t\t\t\t<ComboboxList>\n\t\t\t\t\t\t\t{(value: Value, index: number) => {\n\t\t\t\t\t\t\t\tconst indexed = optionIndex.get(value);\n\t\t\t\t\t\t\t\tif (!indexed) return null;\n\t\t\t\t\t\t\t\tconst { option, sourceIndex } = indexed;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ComboboxItem disabled={option.disabled} index={index} key={option.key ?? option.textValue ?? sourceIndex} value={value}>\n\t\t\t\t\t\t\t\t\t\t<ComboboxItemIndicator>\n\t\t\t\t\t\t\t\t\t\t\t<CheckIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t\t\t\t\t\t\t</ComboboxItemIndicator>\n\t\t\t\t\t\t\t\t\t\t<span className={\"lyds-listbox__option-text\"}>\n\t\t\t\t\t\t\t\t\t\t\t<span>{option.label}</span>\n\t\t\t\t\t\t\t\t\t\t\t{option.description ? <span className={\"lyds-listbox__option-description\"}>{option.description}</span> : null}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</ComboboxItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t</ComboboxList>\n\t\t\t\t\t\t<ComboboxEmpty>{emptyMessage ?? messages.comboboxEmpty}</ComboboxEmpty>\n\t\t\t\t\t</ComboboxPopup>\n\t\t\t\t</ComboboxPositioner>\n\t\t\t</BaseCombobox.Portal>\n\t\t</BaseCombobox.Root>\n\t);\n}\n\nexport const Combobox = Object.assign(ComboboxComponent, {\n\tArrow: BaseCombobox.Arrow,\n\tBackdrop: BaseCombobox.Backdrop,\n\tChip: BaseCombobox.Chip,\n\tChipRemove: BaseCombobox.ChipRemove,\n\tChips: BaseCombobox.Chips,\n\tClear: ComboboxClear,\n\tCollection: BaseCombobox.Collection,\n\tEmpty: ComboboxEmpty,\n\tGroup: BaseCombobox.Group,\n\tGroupLabel: BaseCombobox.GroupLabel,\n\tIcon: BaseCombobox.Icon,\n\tInput: ComboboxInput,\n\tInputGroup: ComboboxInputGroup,\n\tItem: ComboboxItem,\n\tItemIndicator: ComboboxItemIndicator,\n\tLabel: BaseCombobox.Label,\n\tList: ComboboxList,\n\tPopup: ComboboxPopup,\n\tPortal: BaseCombobox.Portal,\n\tPositioner: ComboboxPositioner,\n\tRoot: BaseCombobox.Root,\n\tRow: BaseCombobox.Row,\n\tSeparator: BaseCombobox.Separator,\n\tStatus: BaseCombobox.Status,\n\tTrigger: ComboboxTrigger,\n\tValue: BaseCombobox.Value,\n\tuseFilter: BaseCombobox.useFilter,\n\tuseFilteredItems: BaseCombobox.useFilteredItems\n});\n\nexport const AutocompleteInputGroup = forwardRef<HTMLDivElement, AutocompleteInputGroupProps>(function AutocompleteInputGroup({ className, ...props }, ref) {\n\treturn <BaseAutocomplete.InputGroup {...props} className={withStateClassName(\"lyds-combobox__input-group\", className)} ref={ref} />;\n});\n\nexport const AutocompleteItem = forwardRef<HTMLDivElement, AutocompleteItemProps>(function AutocompleteItem({ className, ...props }, ref) {\n\treturn <BaseAutocomplete.Item {...props} className={withStateClassName(\"lyds-listbox__option\", className)} ref={ref} />;\n});\n\nexport interface AutocompleteOption<Value> {\n\tdisabled?: boolean;\n\tkey?: Key;\n\tlabel: ReactNode;\n\ttextValue?: string;\n\tvalue: Value;\n}\n\nexport interface AutocompleteProps<ItemValue> extends Omit<AutocompleteRootProps<ItemValue>, \"children\" | \"items\"> {\n\t\"aria-describedby\"?: string;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n\tclearLabel?: string;\n\temptyMessage?: ReactNode;\n\tinputProps?: Omit<ComboboxInputProps, \"className\" | \"placeholder\">;\n\tinvalid?: boolean;\n\toptions: readonly AutocompleteOption<ItemValue>[];\n\tplaceholder?: string;\n\tpopupProps?: ComboboxPopupProps;\n\tpositionerProps?: ComboboxPositionerProps;\n\ttriggerLabel?: string;\n}\n\nfunction AutocompleteComponent<ItemValue>({\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\tclassName,\n\tclearLabel,\n\temptyMessage,\n\tinputProps,\n\tinvalid = false,\n\titemToStringValue,\n\toptions,\n\tplaceholder,\n\tpopupProps,\n\tpositionerProps,\n\ttriggerLabel,\n\t...rootProps\n}: AutocompleteProps<ItemValue>) {\n\tconst messages = useMessages();\n\tconst optionIndex = useMemo(() => createOptionIndex<ItemValue, AutocompleteOption<ItemValue>>(options), [options]);\n\tconst stringify = useMemo(\n\t\t() =>\n\t\t\titemToStringValue ??\n\t\t\t((itemValue: ItemValue) => {\n\t\t\t\tconst option = optionIndex.get(itemValue)?.option;\n\t\t\t\treturn option?.textValue ?? (typeof option?.label === \"string\" ? option.label : String(itemValue));\n\t\t\t}),\n\t\t[itemToStringValue, optionIndex]\n\t);\n\n\treturn (\n\t\t<BaseAutocomplete.Root {...rootProps} itemToStringValue={stringify} items={optionIndex.values}>\n\t\t\t<AutocompleteInputGroup className={className}>\n\t\t\t\t<ComboboxInput\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\taria-describedby={ariaDescribedby ?? inputProps?.[\"aria-describedby\"]}\n\t\t\t\t\taria-invalid={invalid || inputProps?.[\"aria-invalid\"] || undefined}\n\t\t\t\t\taria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledby ?? inputProps?.[\"aria-labelledby\"]}\n\t\t\t\t\tautoComplete={inputProps?.autoComplete ?? \"off\"}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t\t<ComboboxClear aria-label={clearLabel ?? messages.autocompleteClear}>\n\t\t\t\t\t<XIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxClear>\n\t\t\t\t<BaseAutocomplete.Trigger aria-label={triggerLabel ?? messages.autocompleteTrigger} className={\"lyds-combobox__trigger\"}>\n\t\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</BaseAutocomplete.Trigger>\n\t\t\t</AutocompleteInputGroup>\n\t\t\t<BaseAutocomplete.Portal>\n\t\t\t\t<ComboboxPositioner {...positionerProps}>\n\t\t\t\t\t<ComboboxPopup {...popupProps}>\n\t\t\t\t\t\t<ComboboxList>\n\t\t\t\t\t\t\t{(value: ItemValue, index: number) => {\n\t\t\t\t\t\t\t\tconst indexed = optionIndex.get(value);\n\t\t\t\t\t\t\t\tif (!indexed) return null;\n\t\t\t\t\t\t\t\tconst { option, sourceIndex } = indexed;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<AutocompleteItem disabled={option.disabled} index={index} key={option.key ?? option.textValue ?? sourceIndex} value={value}>\n\t\t\t\t\t\t\t\t\t\t<span className={\"lyds-listbox__option-text\"}>{option.label}</span>\n\t\t\t\t\t\t\t\t\t</AutocompleteItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t</ComboboxList>\n\t\t\t\t\t\t<ComboboxEmpty>{emptyMessage ?? messages.autocompleteEmpty}</ComboboxEmpty>\n\t\t\t\t\t</ComboboxPopup>\n\t\t\t\t</ComboboxPositioner>\n\t\t\t</BaseAutocomplete.Portal>\n\t\t</BaseAutocomplete.Root>\n\t);\n}\n\nexport const Autocomplete = Object.assign(AutocompleteComponent, {\n\tArrow: BaseAutocomplete.Arrow,\n\tBackdrop: BaseAutocomplete.Backdrop,\n\tClear: ComboboxClear,\n\tCollection: BaseAutocomplete.Collection,\n\tEmpty: ComboboxEmpty,\n\tGroup: BaseAutocomplete.Group,\n\tGroupLabel: BaseAutocomplete.GroupLabel,\n\tIcon: BaseAutocomplete.Icon,\n\tInput: ComboboxInput,\n\tInputGroup: AutocompleteInputGroup,\n\tItem: AutocompleteItem,\n\tList: ComboboxList,\n\tPopup: ComboboxPopup,\n\tPortal: BaseAutocomplete.Portal,\n\tPositioner: ComboboxPositioner,\n\tRoot: BaseAutocomplete.Root,\n\tRow: BaseAutocomplete.Row,\n\tSeparator: BaseAutocomplete.Separator,\n\tStatus: BaseAutocomplete.Status,\n\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M,IAAU,EAAY,IAAI,CAAK;KACrC,IAAI,CAAC,GAAS,OAAO;KACrB,IAAM,EAAE,WAAQ,mBAAgB;KAChC,OACC,kBAAC,GAAD;MAAkB,UAAU,EAAO;MAAiB;MAAkE;MACrH,UAAA,kBAAC,QAAD;OAAM,WAAW;OAA8B,UAAA,EAAO;MAAY,CAAA;KACjD,GAF8C,EAAO,OAAO,EAAO,aAAa,CAEhF;IAEpB,EACa,CAAA,GACd,kBAAC,GAAD,EAAA,UAAgB,KAAgB,EAAS,kBAAiC,CAAA,CAC5D;;EACI,CAAA,EACI,CAAA,CACH;;AAEzB;AAEA,IAAa,IAAe,OAAO,OAAO,GAAuB;CAChE,OAAO,EAAiB;CACxB,UAAU,EAAiB;CAC3B,OAAO;CACP,YAAY,EAAiB;CAC7B,OAAO;CACP,OAAO,EAAiB;CACxB,YAAY,EAAiB;CAC7B,MAAM,EAAiB;CACvB,OAAO;CACP,YAAY;CACZ,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ,EAAiB;CACzB,YAAY;CACZ,MAAM,EAAiB;CACvB,KAAK,EAAiB;CACtB,WAAW,EAAiB;CAC5B,QAAQ,EAAiB;CACzB,SAAS,EAAiB;CAC1B,OAAO,EAAiB;CACxB,WAAW,EAAiB;CAC5B,kBAAkB,EAAiB;AACpC,CAAC"}
|
|
1
|
+
{"version":3,"file":"combobox.js","names":[],"sources":["../../../src/components/selection/combobox.tsx"],"sourcesContent":["import { Autocomplete as BaseAutocomplete, type AutocompleteInputGroupProps, type AutocompleteItemProps, type AutocompleteRootProps } from \"@base-ui/react/autocomplete\";\nimport {\n\tCombobox as BaseCombobox,\n\ttype ComboboxClearProps,\n\ttype ComboboxEmptyProps,\n\ttype ComboboxInputGroupProps,\n\ttype ComboboxInputProps,\n\ttype ComboboxItemIndicatorProps,\n\ttype ComboboxItemProps,\n\ttype ComboboxListProps,\n\ttype ComboboxPopupProps,\n\ttype ComboboxPositionerProps,\n\ttype ComboboxRootProps,\n\ttype ComboboxTriggerProps\n} from \"@base-ui/react/combobox\";\nimport { CaretDownIcon } from \"@phosphor-icons/react/dist/csr/CaretDown\";\nimport { CheckIcon } from \"@phosphor-icons/react/dist/csr/Check\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { forwardRef, useMemo, type Key, type ReactNode } from \"react\";\n\nimport { withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\n\nexport const ComboboxInputGroup = forwardRef<HTMLDivElement, ComboboxInputGroupProps>(function ComboboxInputGroup({ className, ...props }, ref) {\n\treturn <BaseCombobox.InputGroup {...props} className={withStateClassName(\"lyds-combobox__input-group\", className)} ref={ref} />;\n});\n\nexport const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(function ComboboxInput({ className, ...props }, ref) {\n\treturn <BaseCombobox.Input {...props} className={withStateClassName(\"lyds-combobox__input\", className)} ref={ref} />;\n});\n\nexport const ComboboxTrigger = forwardRef<HTMLButtonElement, ComboboxTriggerProps>(function ComboboxTrigger({ className, ...props }, ref) {\n\treturn <BaseCombobox.Trigger {...props} className={withStateClassName(\"lyds-combobox__trigger\", className)} ref={ref} />;\n});\n\nexport const ComboboxClear = forwardRef<HTMLButtonElement, ComboboxClearProps>(function ComboboxClear({ className, ...props }, ref) {\n\treturn <BaseCombobox.Clear {...props} className={withStateClassName(\"lyds-combobox__clear\", className)} ref={ref} />;\n});\n\nexport const ComboboxPositioner = forwardRef<HTMLDivElement, ComboboxPositionerProps>(function ComboboxPositioner({ className, ...props }, ref) {\n\treturn <BaseCombobox.Positioner {...props} className={withStateClassName(\"lyds-listbox__positioner\", className)} ref={ref} />;\n});\n\nexport const ComboboxPopup = forwardRef<HTMLDivElement, ComboboxPopupProps>(function ComboboxPopup({ className, ...props }, ref) {\n\treturn <BaseCombobox.Popup {...props} className={withStateClassName(\"lyds-listbox__popup\", className)} ref={ref} />;\n});\n\nexport const ComboboxList = forwardRef<HTMLDivElement, ComboboxListProps>(function ComboboxList({ className, ...props }, ref) {\n\treturn <BaseCombobox.List {...props} className={withStateClassName(\"lyds-listbox__list\", className)} ref={ref} />;\n});\n\nexport const ComboboxItem = forwardRef<HTMLDivElement, ComboboxItemProps>(function ComboboxItem({ className, ...props }, ref) {\n\treturn <BaseCombobox.Item {...props} className={withStateClassName(\"lyds-listbox__option\", className)} ref={ref} />;\n});\n\nexport const ComboboxItemIndicator = forwardRef<HTMLSpanElement, ComboboxItemIndicatorProps>(function ComboboxItemIndicator({ className, ...props }, ref) {\n\treturn <BaseCombobox.ItemIndicator {...props} className={withStateClassName(\"lyds-listbox__option-indicator\", className)} ref={ref} />;\n});\n\nexport const ComboboxEmpty = forwardRef<HTMLDivElement, ComboboxEmptyProps>(function ComboboxEmpty({ className, ...props }, ref) {\n\treturn <BaseCombobox.Empty {...props} className={withStateClassName(\"lyds-listbox__empty\", className)} ref={ref} />;\n});\n\nexport interface ComboboxOption<Value> {\n\tdescription?: ReactNode;\n\tdisabled?: boolean;\n\tkey?: Key;\n\tlabel: ReactNode;\n\ttextValue?: string;\n\tvalue: Value;\n}\n\ninterface IndexedOption<Option> {\n\toption: Option;\n\tsourceIndex: number;\n}\n\nfunction createOptionIndex<Value, Option extends { value: Value }>(options: readonly Option[]) {\n\tconst values: Value[] = [];\n\tconst lookup = new Map<Value, IndexedOption<Option>>();\n\tlet negativeZero: IndexedOption<Option> | undefined;\n\tlet positiveZero: IndexedOption<Option> | undefined;\n\n\toptions.forEach((option, sourceIndex) => {\n\t\tconst value = option.value;\n\t\tconst indexed = { option, sourceIndex };\n\t\tvalues.push(value);\n\n\t\tif (typeof value === \"number\" && value === 0) {\n\t\t\tif (Object.is(value, -0)) negativeZero ??= indexed;\n\t\t\telse positiveZero ??= indexed;\n\t\t\treturn;\n\t\t}\n\n\t\tif (!lookup.has(value)) lookup.set(value, indexed);\n\t});\n\n\treturn {\n\t\tvalues,\n\t\tget(value: Value) {\n\t\t\tif (typeof value === \"number\" && value === 0) {\n\t\t\t\treturn Object.is(value, -0) ? negativeZero : positiveZero;\n\t\t\t}\n\t\t\treturn lookup.get(value);\n\t\t}\n\t};\n}\n\nexport interface ComboboxProps<Value> extends Omit<ComboboxRootProps<Value, false>, \"children\" | \"items\" | \"multiple\"> {\n\t\"aria-describedby\"?: string;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n\tclearLabel?: string;\n\temptyMessage?: ReactNode;\n\tinputProps?: Omit<ComboboxInputProps, \"className\" | \"placeholder\">;\n\tinvalid?: boolean;\n\toptions: readonly ComboboxOption<Value>[];\n\tplaceholder?: string;\n\tpopupProps?: ComboboxPopupProps;\n\tpositionerProps?: ComboboxPositionerProps;\n\ttriggerLabel?: string;\n}\n\nfunction ComboboxComponent<Value>({\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\tclassName,\n\tclearLabel,\n\temptyMessage,\n\tinputProps,\n\tinvalid = false,\n\titemToStringLabel,\n\toptions,\n\tplaceholder,\n\tpopupProps,\n\tpositionerProps,\n\ttriggerLabel,\n\t...rootProps\n}: ComboboxProps<Value>) {\n\tconst messages = useMessages();\n\tconst optionIndex = useMemo(() => createOptionIndex<Value, ComboboxOption<Value>>(options), [options]);\n\tconst stringify = useMemo(\n\t\t() =>\n\t\t\titemToStringLabel ??\n\t\t\t((itemValue: Value) => {\n\t\t\t\tconst option = optionIndex.get(itemValue)?.option;\n\t\t\t\treturn option?.textValue ?? (typeof option?.label === \"string\" ? option.label : String(itemValue));\n\t\t\t}),\n\t\t[itemToStringLabel, optionIndex]\n\t);\n\n\treturn (\n\t\t<BaseCombobox.Root {...rootProps} itemToStringLabel={stringify} items={optionIndex.values}>\n\t\t\t<ComboboxInputGroup className={className}>\n\t\t\t\t<ComboboxInput\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\taria-describedby={ariaDescribedby ?? inputProps?.[\"aria-describedby\"]}\n\t\t\t\t\taria-invalid={invalid || inputProps?.[\"aria-invalid\"] || undefined}\n\t\t\t\t\taria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledby ?? inputProps?.[\"aria-labelledby\"]}\n\t\t\t\t\tautoComplete={inputProps?.autoComplete ?? \"off\"}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t\t<ComboboxClear aria-label={clearLabel ?? messages.comboboxClear}>\n\t\t\t\t\t<XIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxClear>\n\t\t\t\t<ComboboxTrigger aria-label={triggerLabel ?? messages.comboboxTrigger}>\n\t\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxTrigger>\n\t\t\t</ComboboxInputGroup>\n\t\t\t<BaseCombobox.Portal>\n\t\t\t\t<ComboboxPositioner {...positionerProps}>\n\t\t\t\t\t<ComboboxPopup {...popupProps}>\n\t\t\t\t\t\t<ComboboxList>\n\t\t\t\t\t\t\t{(value: Value, index: number) => {\n\t\t\t\t\t\t\t\tconst indexed = optionIndex.get(value);\n\t\t\t\t\t\t\t\tif (!indexed) return null;\n\t\t\t\t\t\t\t\tconst { option, sourceIndex } = indexed;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ComboboxItem disabled={option.disabled} index={index} key={option.key ?? option.textValue ?? sourceIndex} value={value}>\n\t\t\t\t\t\t\t\t\t\t<ComboboxItemIndicator>\n\t\t\t\t\t\t\t\t\t\t\t<CheckIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t\t\t\t\t\t\t</ComboboxItemIndicator>\n\t\t\t\t\t\t\t\t\t\t<span className={\"lyds-listbox__option-text\"}>\n\t\t\t\t\t\t\t\t\t\t\t<span>{option.label}</span>\n\t\t\t\t\t\t\t\t\t\t\t{option.description ? <span className={\"lyds-listbox__option-description\"}>{option.description}</span> : null}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</ComboboxItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t</ComboboxList>\n\t\t\t\t\t\t<ComboboxEmpty>{emptyMessage ?? messages.comboboxEmpty}</ComboboxEmpty>\n\t\t\t\t\t</ComboboxPopup>\n\t\t\t\t</ComboboxPositioner>\n\t\t\t</BaseCombobox.Portal>\n\t\t</BaseCombobox.Root>\n\t);\n}\n\nexport const Combobox = Object.assign(ComboboxComponent, {\n\tArrow: BaseCombobox.Arrow,\n\tBackdrop: BaseCombobox.Backdrop,\n\tChip: BaseCombobox.Chip,\n\tChipRemove: BaseCombobox.ChipRemove,\n\tChips: BaseCombobox.Chips,\n\tClear: ComboboxClear,\n\tCollection: BaseCombobox.Collection,\n\tEmpty: ComboboxEmpty,\n\tGroup: BaseCombobox.Group,\n\tGroupLabel: BaseCombobox.GroupLabel,\n\tIcon: BaseCombobox.Icon,\n\tInput: ComboboxInput,\n\tInputGroup: ComboboxInputGroup,\n\tItem: ComboboxItem,\n\tItemIndicator: ComboboxItemIndicator,\n\tLabel: BaseCombobox.Label,\n\tList: ComboboxList,\n\tPopup: ComboboxPopup,\n\tPortal: BaseCombobox.Portal,\n\tPositioner: ComboboxPositioner,\n\tRoot: BaseCombobox.Root,\n\tRow: BaseCombobox.Row,\n\tSeparator: BaseCombobox.Separator,\n\tStatus: BaseCombobox.Status,\n\tTrigger: ComboboxTrigger,\n\tValue: BaseCombobox.Value,\n\tuseFilter: BaseCombobox.useFilter,\n\tuseFilteredItems: BaseCombobox.useFilteredItems\n});\n\nexport const AutocompleteInputGroup = forwardRef<HTMLDivElement, AutocompleteInputGroupProps>(function AutocompleteInputGroup({ className, ...props }, ref) {\n\treturn <BaseAutocomplete.InputGroup {...props} className={withStateClassName(\"lyds-combobox__input-group\", className)} ref={ref} />;\n});\n\nexport const AutocompleteItem = forwardRef<HTMLDivElement, AutocompleteItemProps>(function AutocompleteItem({ className, ...props }, ref) {\n\treturn <BaseAutocomplete.Item {...props} className={withStateClassName(\"lyds-listbox__option\", className)} ref={ref} />;\n});\n\nexport interface AutocompleteOption<Value> {\n\tdisabled?: boolean;\n\tkey?: Key;\n\tlabel: ReactNode;\n\ttextValue?: string;\n\tvalue: Value;\n}\n\nexport interface AutocompleteProps<ItemValue> extends Omit<AutocompleteRootProps<ItemValue>, \"children\" | \"items\"> {\n\t\"aria-describedby\"?: string;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n\tclearLabel?: string;\n\temptyMessage?: ReactNode;\n\tinputProps?: Omit<ComboboxInputProps, \"className\" | \"placeholder\">;\n\tinvalid?: boolean;\n\toptions: readonly AutocompleteOption<ItemValue>[];\n\tplaceholder?: string;\n\tpopupProps?: ComboboxPopupProps;\n\tpositionerProps?: ComboboxPositionerProps;\n\ttriggerLabel?: string;\n}\n\nfunction AutocompleteComponent<ItemValue>({\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\tclassName,\n\tclearLabel,\n\temptyMessage,\n\tinputProps,\n\tinvalid = false,\n\titemToStringValue,\n\toptions,\n\tplaceholder,\n\tpopupProps,\n\tpositionerProps,\n\ttriggerLabel,\n\t...rootProps\n}: AutocompleteProps<ItemValue>) {\n\tconst messages = useMessages();\n\tconst optionIndex = useMemo(() => createOptionIndex<ItemValue, AutocompleteOption<ItemValue>>(options), [options]);\n\tconst stringify = useMemo(\n\t\t() =>\n\t\t\titemToStringValue ??\n\t\t\t((itemValue: ItemValue) => {\n\t\t\t\tconst option = optionIndex.get(itemValue)?.option;\n\t\t\t\treturn option?.textValue ?? (typeof option?.label === \"string\" ? option.label : String(itemValue));\n\t\t\t}),\n\t\t[itemToStringValue, optionIndex]\n\t);\n\n\treturn (\n\t\t<BaseAutocomplete.Root {...rootProps} itemToStringValue={stringify} items={optionIndex.values}>\n\t\t\t<AutocompleteInputGroup className={className}>\n\t\t\t\t<ComboboxInput\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\taria-describedby={ariaDescribedby ?? inputProps?.[\"aria-describedby\"]}\n\t\t\t\t\taria-invalid={invalid || inputProps?.[\"aria-invalid\"] || undefined}\n\t\t\t\t\taria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledby ?? inputProps?.[\"aria-labelledby\"]}\n\t\t\t\t\tautoComplete={inputProps?.autoComplete ?? \"off\"}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t\t<ComboboxClear aria-label={clearLabel ?? messages.autocompleteClear}>\n\t\t\t\t\t<XIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxClear>\n\t\t\t\t<BaseAutocomplete.Trigger aria-label={triggerLabel ?? messages.autocompleteTrigger} className={\"lyds-combobox__trigger\"}>\n\t\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</BaseAutocomplete.Trigger>\n\t\t\t</AutocompleteInputGroup>\n\t\t\t<BaseAutocomplete.Portal>\n\t\t\t\t<ComboboxPositioner {...positionerProps}>\n\t\t\t\t\t<ComboboxPopup {...popupProps}>\n\t\t\t\t\t\t<ComboboxList>\n\t\t\t\t\t\t\t{(value: ItemValue, index: number) => {\n\t\t\t\t\t\t\t\tconst indexed = optionIndex.get(value);\n\t\t\t\t\t\t\t\tif (!indexed) return null;\n\t\t\t\t\t\t\t\tconst { option, sourceIndex } = indexed;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<AutocompleteItem disabled={option.disabled} index={index} key={option.key ?? option.textValue ?? sourceIndex} value={value}>\n\t\t\t\t\t\t\t\t\t\t<span className={\"lyds-listbox__option-text\"}>{option.label}</span>\n\t\t\t\t\t\t\t\t\t</AutocompleteItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t</ComboboxList>\n\t\t\t\t\t\t<ComboboxEmpty>{emptyMessage ?? messages.autocompleteEmpty}</ComboboxEmpty>\n\t\t\t\t\t</ComboboxPopup>\n\t\t\t\t</ComboboxPositioner>\n\t\t\t</BaseAutocomplete.Portal>\n\t\t</BaseAutocomplete.Root>\n\t);\n}\n\nexport const Autocomplete = Object.assign(AutocompleteComponent, {\n\tArrow: BaseAutocomplete.Arrow,\n\tBackdrop: BaseAutocomplete.Backdrop,\n\tClear: ComboboxClear,\n\tCollection: BaseAutocomplete.Collection,\n\tEmpty: ComboboxEmpty,\n\tGroup: BaseAutocomplete.Group,\n\tGroupLabel: BaseAutocomplete.GroupLabel,\n\tIcon: BaseAutocomplete.Icon,\n\tInput: ComboboxInput,\n\tInputGroup: AutocompleteInputGroup,\n\tItem: AutocompleteItem,\n\tList: ComboboxList,\n\tPopup: ComboboxPopup,\n\tPortal: BaseAutocomplete.Portal,\n\tPositioner: ComboboxPositioner,\n\tRoot: BaseAutocomplete.Root,\n\tRow: BaseAutocomplete.Row,\n\tSeparator: BaseAutocomplete.Separator,\n\tStatus: BaseAutocomplete.Status,\n\tTrigger: BaseAutocomplete.Trigger,\n\tValue: BaseAutocomplete.Value,\n\tuseFilter: BaseAutocomplete.useFilter,\n\tuseFilteredItems: BaseAutocomplete.useFilteredItems\n});\n"],"mappings":";;;;;;;;;;;AAuBA,IAAa,IAAqB,EAAoD,SAA4B,EAAE,cAAW,GAAG,KAAS,GAAK;CAC/I,OAAO,kBAAC,EAAa,YAAd;EAAyB,GAAI;EAAO,WAAW,EAAmB,8BAA8B,CAAS;EAAQ;CAAM,CAAA;AAC/H,CAAC,GAEY,IAAgB,EAAiD,SAAuB,EAAE,cAAW,GAAG,KAAS,GAAK;CAClI,OAAO,kBAAC,EAAa,OAAd;EAAoB,GAAI;EAAO,WAAW,EAAmB,wBAAwB,CAAS;EAAQ;CAAM,CAAA;AACpH,CAAC,GAEY,IAAkB,EAAoD,SAAyB,EAAE,cAAW,GAAG,KAAS,GAAK;CACzI,OAAO,kBAAC,EAAa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AO;CACP,YAAY;CACZ,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ,EAAiB;CACzB,YAAY;CACZ,MAAM,EAAiB;CACvB,KAAK,EAAiB;CACtB,WAAW,EAAiB;CAC5B,QAAQ,EAAiB;CACzB,SAAS,EAAiB;CAC1B,OAAO,EAAiB;CACxB,WAAW,EAAiB;CAC5B,kBAAkB,EAAiB;AACpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controls.js","names":[],"sources":["../../../src/components/selection/controls.tsx"],"sourcesContent":["import { Checkbox as BaseCheckbox, type CheckboxRootProps } from \"@base-ui/react/checkbox\";\nimport { CheckboxGroup as BaseCheckboxGroup, type CheckboxGroupProps as BaseCheckboxGroupProps } from \"@base-ui/react/checkbox-group\";\nimport { Radio as BaseRadio, type RadioRootProps } from \"@base-ui/react/radio\";\nimport { RadioGroup as BaseRadioGroup, type RadioGroupProps as BaseRadioGroupProps } from \"@base-ui/react/radio-group\";\nimport { Slider as BaseSlider, type SliderRootProps } from \"@base-ui/react/slider\";\nimport { Switch as BaseSwitch, type SwitchRootProps } from \"@base-ui/react/switch\";\nimport { Toggle as BaseToggle, type ToggleProps as BaseToggleProps } from \"@base-ui/react/toggle\";\nimport { ToggleGroup as BaseToggleGroup, type ToggleGroupProps as BaseToggleGroupProps } from \"@base-ui/react/toggle-group\";\nimport { CheckIcon } from \"@phosphor-icons/react/dist/csr/Check\";\nimport { MinusIcon } from \"@phosphor-icons/react/dist/csr/Minus\";\nimport { forwardRef, useCallback, useId, useState, type ForwardedRef, type JSX, type ReactNode, type RefAttributes } from \"react\";\n\nimport { cx, withStateClassName, type AccessibleName } from \"@/internal\";\n\nfunction CheckGlyph({ indeterminate = false }: { indeterminate?: boolean }) {\n\treturn indeterminate ? <MinusIcon aria-hidden=\"true\" weight=\"bold\" /> : <CheckIcon aria-hidden=\"true\" weight=\"bold\" />;\n}\n\nexport interface CheckboxProps extends CheckboxRootProps {\n\tindicator?: ReactNode;\n}\n\nexport const Checkbox = forwardRef<HTMLElement, CheckboxProps>(function Checkbox({ children, className, indicator, indeterminate, ...props }, ref) {\n\treturn (\n\t\t<BaseCheckbox.Root {...props} className={withStateClassName(\"lyds-checkbox\", className)} indeterminate={indeterminate} ref={ref}>\n\t\t\t<BaseCheckbox.Indicator className={\"lyds-checkbox__indicator\"} keepMounted>\n\t\t\t\t{indicator ?? <CheckGlyph indeterminate={indeterminate ?? false} />}\n\t\t\t</BaseCheckbox.Indicator>\n\t\t\t{children}\n\t\t</BaseCheckbox.Root>\n\t);\n});\n\nexport type CheckboxGroupProps = BaseCheckboxGroupProps;\n\nexport const CheckboxGroup = forwardRef<HTMLDivElement, CheckboxGroupProps>(function CheckboxGroup({ className, ...props }, ref) {\n\treturn <BaseCheckboxGroup {...props} className={withStateClassName(\"lyds-choice-group\", className)} ref={ref} />;\n});\n\n/**\n * The wrapping <label> makes the whole row a hit target, but it also makes every word inside it\n * part of the control's accessible name — including the description. Naming the control from the\n * title and describing it from the description keeps the row clickable without reading the\n * supporting copy out as part of the name. The visible title always wins over an `aria-label`,\n * which is what WCAG 2.5.3 asks for; pass `aria-labelledby` to point somewhere else entirely.\n */\nfunction useChoiceCopyIds(description: ReactNode) {\n\tconst id = useId();\n\treturn { titleId: `${id}-title`, descriptionId: description ? `${id}-description` : undefined };\n}\n\nexport interface CheckboxItemProps extends CheckboxProps {\n\tlabel: ReactNode;\n\tdescription?: ReactNode;\n\twrapperClassName?: string;\n}\n\nexport const CheckboxItem = forwardRef<HTMLElement, CheckboxItemProps>(function CheckboxItem({ description, label, wrapperClassName, ...props }, ref) {\n\tconst { titleId, descriptionId } = useChoiceCopyIds(description);\n\n\treturn (\n\t\t<label className={cx(\"lyds-choice\", wrapperClassName)}>\n\t\t\t<Checkbox {...props} ref={ref} aria-labelledby={props[\"aria-labelledby\"] ?? titleId} aria-describedby={props[\"aria-describedby\"] ?? descriptionId} />\n\t\t\t<span className={\"lyds-choice__copy\"}>\n\t\t\t\t<span className={\"lyds-choice__title\"} id={titleId}>\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t\t{description ? (\n\t\t\t\t\t<span className={\"lyds-choice__description\"} id={descriptionId}>\n\t\t\t\t\t\t{description}\n\t\t\t\t\t</span>\n\t\t\t\t) : null}\n\t\t\t</span>\n\t\t</label>\n\t);\n});\n\nexport type RadioGroupProps<Value = string> = BaseRadioGroupProps<Value>;\n\ntype RadioGroupComponent = <Value = string>(props: RadioGroupProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;\n\nexport const RadioGroup = forwardRef(function RadioGroup<Value = string>({ className, ...props }: RadioGroupProps<Value>, ref: ForwardedRef<HTMLDivElement>) {\n\treturn <BaseRadioGroup {...props} className={withStateClassName(\"lyds-choice-group\", className)} ref={ref} />;\n}) as RadioGroupComponent;\n\nexport type RadioProps<Value = string> = RadioRootProps<Value>;\n\ntype RadioComponent = <Value = string>(props: RadioProps<Value> & RefAttributes<HTMLElement>) => JSX.Element;\n\nexport const Radio = forwardRef(function Radio<Value = string>({ children, className, ...props }: RadioProps<Value>, ref: ForwardedRef<HTMLElement>) {\n\treturn (\n\t\t<BaseRadio.Root {...props} className={withStateClassName(\"lyds-radio\", className)} ref={ref}>\n\t\t\t<BaseRadio.Indicator className={\"lyds-radio__indicator\"} keepMounted />\n\t\t\t{children}\n\t\t</BaseRadio.Root>\n\t);\n}) as RadioComponent;\n\nexport interface RadioItemProps<Value = string> extends RadioProps<Value> {\n\tlabel: ReactNode;\n\tdescription?: ReactNode;\n\twrapperClassName?: string;\n}\n\ntype RadioItemComponent = <Value = string>(props: RadioItemProps<Value> & RefAttributes<HTMLElement>) => JSX.Element;\n\nexport const RadioItem = forwardRef(function RadioItem<Value = string>({ description, label, wrapperClassName, ...props }: RadioItemProps<Value>, ref: ForwardedRef<HTMLElement>) {\n\tconst { titleId, descriptionId } = useChoiceCopyIds(description);\n\n\treturn (\n\t\t<label className={cx(\"lyds-choice\", wrapperClassName)}>\n\t\t\t<Radio {...props} ref={ref} aria-labelledby={props[\"aria-labelledby\"] ?? titleId} aria-describedby={props[\"aria-describedby\"] ?? descriptionId} />\n\t\t\t<span className={\"lyds-choice__copy\"}>\n\t\t\t\t<span className={\"lyds-choice__title\"} id={titleId}>\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t\t{description ? (\n\t\t\t\t\t<span className={\"lyds-choice__description\"} id={descriptionId}>\n\t\t\t\t\t\t{description}\n\t\t\t\t\t</span>\n\t\t\t\t) : null}\n\t\t\t</span>\n\t\t</label>\n\t);\n}) as RadioItemComponent;\n\nexport interface SwitchProps extends SwitchRootProps {\n\tchildren?: ReactNode;\n}\n\nexport const Switch = forwardRef<HTMLElement, SwitchProps>(function Switch({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseSwitch.Root {...props} className={withStateClassName(\"lyds-switch\", className)} ref={ref}>\n\t\t\t<span aria-hidden=\"true\" className={\"lyds-switch__signal\"} />\n\t\t\t<BaseSwitch.Thumb className={\"lyds-switch__thumb\"} />\n\t\t\t{children}\n\t\t</BaseSwitch.Root>\n\t);\n});\n\nexport interface SliderProps<Value extends number | readonly number[] = number> extends SliderRootProps<Value> {\n\tgetAriaLabel?: (index: number) => string;\n\tgetAriaValueText?: (formattedValue: string, value: number, index: number) => string;\n\tshowValue?: boolean;\n}\n\ntype SliderComponent = <Value extends number | readonly number[] = number>(props: SliderProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;\n\nfunction getThumbCount(value: number | readonly number[] | undefined): number {\n\treturn Array.isArray(value) ? Math.max(value.length, 1) : 1;\n}\n\nexport const Slider = forwardRef(function Slider<Value extends number | readonly number[] = number>(\n\t{\n\t\t\"aria-describedby\": ariaDescribedby,\n\t\t\"aria-label\": ariaLabel,\n\t\t\"aria-labelledby\": ariaLabelledby,\n\t\tclassName,\n\t\tdefaultValue,\n\t\tgetAriaLabel,\n\t\tgetAriaValueText,\n\t\tshowValue = false,\n\t\tvalue,\n\t\t...props\n\t}: SliderProps<Value>,\n\tref: ForwardedRef<HTMLDivElement>\n) {\n\tconst thumbCount = getThumbCount(value ?? defaultValue);\n\tconst fallbackThumbLabel = ariaLabel ? (index: number) => (thumbCount === 1 ? ariaLabel : `${ariaLabel} ${index + 1}`) : undefined;\n\t// Base UI owns the thumb inputs, so these two relationships have to be applied to the nodes it\n\t// renders. An inline callback would detach and reattach on every render; aria-labelledby is only\n\t// ever added because Base UI sets its own, while aria-describedby is ours to clear.\n\tconst applyThumbDescription = useCallback(\n\t\t(input: HTMLInputElement | null) => {\n\t\t\tif (!input) return;\n\t\t\tif (ariaDescribedby) input.setAttribute(\"aria-describedby\", ariaDescribedby);\n\t\t\telse input.removeAttribute(\"aria-describedby\");\n\t\t\tif (ariaLabelledby && !getAriaLabel) input.setAttribute(\"aria-labelledby\", ariaLabelledby);\n\t\t},\n\t\t[ariaDescribedby, ariaLabelledby, getAriaLabel]\n\t);\n\n\treturn (\n\t\t<BaseSlider.Root {...props} aria-label={ariaLabel} aria-labelledby={ariaLabelledby} className={withStateClassName(\"lyds-slider\", className)} defaultValue={defaultValue} ref={ref} value={value}>\n\t\t\t{showValue ? <BaseSlider.Value className={\"lyds-slider__value\"} /> : null}\n\t\t\t<BaseSlider.Control className={\"lyds-slider__control\"}>\n\t\t\t\t<BaseSlider.Track className={\"lyds-slider__track\"}>\n\t\t\t\t\t<BaseSlider.Indicator className={\"lyds-slider__indicator\"} />\n\t\t\t\t\t{Array.from({ length: thumbCount }, (_, index) => (\n\t\t\t\t\t\t<BaseSlider.Thumb\n\t\t\t\t\t\t\tclassName={\"lyds-slider__thumb\"}\n\t\t\t\t\t\t\tgetAriaLabel={getAriaLabel ?? fallbackThumbLabel}\n\t\t\t\t\t\t\tgetAriaValueText={getAriaValueText}\n\t\t\t\t\t\t\tinputRef={applyThumbDescription}\n\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\tkey={index}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</BaseSlider.Track>\n\t\t\t</BaseSlider.Control>\n\t\t</BaseSlider.Root>\n\t);\n}) as SliderComponent;\n\nexport interface ToggleProps<Value extends string = string> extends BaseToggleProps<Value> {\n\tvariant?: \"standard\" | \"quiet\";\n}\n\ntype ToggleComponent = <Value extends string = string>(props: ToggleProps<Value> & RefAttributes<HTMLButtonElement>) => JSX.Element;\n\nexport const Toggle = forwardRef(function Toggle<Value extends string = string>({ className, variant = \"standard\", ...props }: ToggleProps<Value>, ref: ForwardedRef<HTMLButtonElement>) {\n\treturn <BaseToggle {...props} className={state => cx(\"lyds-toggle\", variant === \"quiet\" && \"lyds-toggle--quiet\", typeof className === \"function\" ? className(state) : className)} ref={ref} />;\n}) as ToggleComponent;\n\nexport type ToggleGroupProps<Value extends string = string> = BaseToggleGroupProps<Value>;\n\ntype ToggleGroupComponent = <Value extends string = string>(props: ToggleGroupProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;\n\nexport const ToggleGroup = forwardRef(function ToggleGroup<Value extends string = string>({ className, ...props }: ToggleGroupProps<Value>, ref: ForwardedRef<HTMLDivElement>) {\n\treturn <BaseToggleGroup {...props} className={withStateClassName(\"lyds-toggle-group\", className)} ref={ref} />;\n}) as ToggleGroupComponent;\n\ninterface SegmentedControlOwnProps<Value extends string = string> extends Omit<\n\tBaseToggleGroupProps<Value>,\n\t\"aria-label\" | \"aria-labelledby\" | \"aria-readonly\" | \"defaultValue\" | \"multiple\" | \"onValueChange\" | \"value\"\n> {\n\tallowEmpty?: boolean;\n\tdefaultValue?: Value | null;\n\tname?: string;\n\tonValueChange?: (value: Value | null, details: BaseToggleGroup.ChangeEventDetails) => void;\n\tsize?: \"sm\" | \"md\";\n\tvalue?: Value | null;\n}\n\n/** The segments name themselves; the group they belong to does not, so it has to be told. */\nexport type SegmentedControlProps<Value extends string = string> = SegmentedControlOwnProps<Value> & AccessibleName;\n\ntype SegmentedControlComponent = <Value extends string = string>(props: SegmentedControlProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;\n\nexport const SegmentedControl = forwardRef(function SegmentedControl<Value extends string = string>(\n\t{\n\t\tallowEmpty = false,\n\t\t\"aria-label\": ariaLabel,\n\t\t\"aria-labelledby\": ariaLabelledby,\n\t\tclassName,\n\t\tdefaultValue = null,\n\t\tdisabled = false,\n\t\tname,\n\t\tonValueChange,\n\t\tsize = \"md\",\n\t\tvalue,\n\t\t...props\n\t}: SegmentedControlProps<Value>,\n\tref: ForwardedRef<HTMLDivElement>\n) {\n\tconst controlled = value !== undefined;\n\tconst [internalValue, setInternalValue] = useState<Value | null>(defaultValue);\n\tconst currentValue = controlled ? value : internalValue;\n\n\treturn (\n\t\t<>\n\t\t\t<BaseToggleGroup\n\t\t\t\t{...props}\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\taria-labelledby={ariaLabelledby}\n\t\t\t\tclassName={withStateClassName(\"lyds-segmented-control\", className)}\n\t\t\t\tdata-size={size}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tmultiple={false}\n\t\t\t\tonValueChange={(nextValues, details) => {\n\t\t\t\t\tconst nextValue = nextValues[0] ?? null;\n\t\t\t\t\tif (!allowEmpty && nextValue === null) return;\n\t\t\t\t\tonValueChange?.(nextValue, details);\n\t\t\t\t\tif (details.isCanceled) return;\n\t\t\t\t\tif (!controlled) setInternalValue(nextValue);\n\t\t\t\t}}\n\t\t\t\tref={ref}\n\t\t\t\tvalue={currentValue === null ? [] : [currentValue]}\n\t\t\t/>\n\t\t\t{name ? <input disabled={disabled} name={name} type=\"hidden\" value={currentValue ?? \"\"} /> : null}\n\t\t</>\n\t);\n}) as SegmentedControlComponent;\n\nexport const SegmentedControlItem = Toggle;\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,EAAW,EAAE,mBAAgB,MAAsC;CAC3E,OAAuB,EAAhB,IAAiB,IAAiD,GAAlD;EAAW,eAAY;EAAO,QAAO;CAAQ,CAAiD;AACtH;AAMA,IAAa,IAAW,EAAuC,SAAkB,EAAE,aAAU,cAAW,cA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,EAAE,cAAW,GAAG,KAAkC,GAAmC;CAC9K,OAAO,kBAAC,GAAD;EAAiB,GAAI;EAAO,WAAW,EAAmB,qBAAqB,CAAS;EAAQ;CAAM,CAAA;AAC9G,CAAC,GAmBY,IAAmB,EAAW,SAC1C,EACC,gBAAa,IACb,cAAc,GACd,mBAAmB,GACnB,cACA,kBAAe,MACf,cAAW,IACX,SACA,kBACA,UAAO,MACP,UACA,GAAG,KAEJ,GACC;CACD,IAAM,IAAa,MAAU,KAAA,GACvB,CAAC,GAAe,KAAoB,EAAuB,CAAY,GACvE,IAAe,IAAa,IAAQ;CAE1C,OACC,kBAAA,GAAA,EAAA,UAAA,CACC,kBAAC,GAAD;EACC,GAAI;EACJ,cAAY;EACZ,mBAAiB;EACjB,WAAW,EAAmB,0BAA0B,CAAS;EACjE,aAAW;EACD;EACV,UAAU;EACV,gBAAgB,GAAY,MAAY;GACvC,IAAM,IAAY,EAAW,MAAM;GAC/B,CAAC,KAAc,MAAc,UACjC,IAAgB,GAAW,CAAO,GAC9B,GAAQ,eACP,KAAY,EAAiB,CAAS;EAC5C;EACK;EACL,OAAO,MAAiB,OAAO,CAAC,IAAI,CAAC,CAAY;CACjD,CAAA,GACA,IAAO,kBAAC,SAAD;EAAiB;EAAgB;EAAM,MAAK;EAAS,OAAO,KAAgB;CAAK,CAAA,IAAI,IAC5F,EAAA,CAAA;AAEJ,CAAC,GAEY,IAAuB"}
|
|
1
|
+
{"version":3,"file":"controls.js","names":[],"sources":["../../../src/components/selection/controls.tsx"],"sourcesContent":["import { Checkbox as BaseCheckbox, type CheckboxRootProps } from \"@base-ui/react/checkbox\";\nimport { CheckboxGroup as BaseCheckboxGroup, type CheckboxGroupProps as BaseCheckboxGroupProps } from \"@base-ui/react/checkbox-group\";\nimport { Radio as BaseRadio, type RadioRootProps } from \"@base-ui/react/radio\";\nimport { RadioGroup as BaseRadioGroup, type RadioGroupProps as BaseRadioGroupProps } from \"@base-ui/react/radio-group\";\nimport { Slider as BaseSlider, type SliderRootProps } from \"@base-ui/react/slider\";\nimport { Switch as BaseSwitch, type SwitchRootProps } from \"@base-ui/react/switch\";\nimport { Toggle as BaseToggle, type ToggleProps as BaseToggleProps } from \"@base-ui/react/toggle\";\nimport { ToggleGroup as BaseToggleGroup, type ToggleGroupProps as BaseToggleGroupProps } from \"@base-ui/react/toggle-group\";\nimport { CheckIcon } from \"@phosphor-icons/react/dist/csr/Check\";\nimport { MinusIcon } from \"@phosphor-icons/react/dist/csr/Minus\";\nimport { forwardRef, useCallback, useId, useState, type ForwardedRef, type JSX, type ReactNode, type RefAttributes } from \"react\";\n\nimport { cx, withStateClassName, type AccessibleName } from \"@/internal\";\n\nfunction CheckGlyph({ indeterminate = false }: { indeterminate?: boolean }) {\n\treturn indeterminate ? <MinusIcon aria-hidden=\"true\" weight=\"bold\" /> : <CheckIcon aria-hidden=\"true\" weight=\"bold\" />;\n}\n\nexport interface CheckboxProps extends CheckboxRootProps {\n\tindicator?: ReactNode;\n}\n\nexport const Checkbox = forwardRef<HTMLElement, CheckboxProps>(function Checkbox({ children, className, indicator, indeterminate, ...props }, ref) {\n\treturn (\n\t\t<BaseCheckbox.Root {...props} className={withStateClassName(\"lyds-checkbox\", className)} indeterminate={indeterminate} ref={ref}>\n\t\t\t<BaseCheckbox.Indicator className={\"lyds-checkbox__indicator\"} keepMounted>\n\t\t\t\t{indicator ?? <CheckGlyph indeterminate={indeterminate ?? false} />}\n\t\t\t</BaseCheckbox.Indicator>\n\t\t\t{children}\n\t\t</BaseCheckbox.Root>\n\t);\n});\n\nexport type CheckboxGroupProps = BaseCheckboxGroupProps;\n\nexport const CheckboxGroup = forwardRef<HTMLDivElement, CheckboxGroupProps>(function CheckboxGroup({ className, ...props }, ref) {\n\treturn <BaseCheckboxGroup {...props} className={withStateClassName(\"lyds-choice-group\", className)} ref={ref} />;\n});\n\n/**\n * The wrapping <label> makes the whole row a hit target, but it also makes every word inside it\n * part of the control's accessible name — including the description. Naming the control from the\n * title and describing it from the description keeps the row clickable without reading the\n * supporting copy out as part of the name. The visible title always wins over an `aria-label`,\n * which is what WCAG 2.5.3 asks for; pass `aria-labelledby` to point somewhere else entirely.\n */\nfunction useChoiceCopyIds(description: ReactNode) {\n\tconst id = useId();\n\treturn { titleId: `${id}-title`, descriptionId: description ? `${id}-description` : undefined };\n}\n\nexport interface CheckboxItemProps extends CheckboxProps {\n\tlabel: ReactNode;\n\tdescription?: ReactNode;\n\twrapperClassName?: string;\n}\n\nexport const CheckboxItem = forwardRef<HTMLElement, CheckboxItemProps>(function CheckboxItem({ description, label, wrapperClassName, ...props }, ref) {\n\tconst { titleId, descriptionId } = useChoiceCopyIds(description);\n\n\treturn (\n\t\t<label className={cx(\"lyds-choice\", wrapperClassName)}>\n\t\t\t<Checkbox {...props} ref={ref} aria-labelledby={props[\"aria-labelledby\"] ?? titleId} aria-describedby={props[\"aria-describedby\"] ?? descriptionId} />\n\t\t\t<span className={\"lyds-choice__copy\"}>\n\t\t\t\t<span className={\"lyds-choice__title\"} id={titleId}>\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t\t{description ? (\n\t\t\t\t\t<span className={\"lyds-choice__description\"} id={descriptionId}>\n\t\t\t\t\t\t{description}\n\t\t\t\t\t</span>\n\t\t\t\t) : null}\n\t\t\t</span>\n\t\t</label>\n\t);\n});\n\nexport type RadioGroupProps<Value = string> = BaseRadioGroupProps<Value>;\n\ntype RadioGroupComponent = <Value = string>(props: RadioGroupProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;\n\nexport const RadioGroup = forwardRef(function RadioGroup<Value = string>({ className, ...props }: RadioGroupProps<Value>, ref: ForwardedRef<HTMLDivElement>) {\n\treturn <BaseRadioGroup {...props} className={withStateClassName(\"lyds-choice-group\", className)} ref={ref} />;\n}) as RadioGroupComponent;\n\nexport type RadioProps<Value = string> = RadioRootProps<Value>;\n\ntype RadioComponent = <Value = string>(props: RadioProps<Value> & RefAttributes<HTMLElement>) => JSX.Element;\n\nexport const Radio = forwardRef(function Radio<Value = string>({ children, className, ...props }: RadioProps<Value>, ref: ForwardedRef<HTMLElement>) {\n\treturn (\n\t\t<BaseRadio.Root {...props} className={withStateClassName(\"lyds-radio\", className)} ref={ref}>\n\t\t\t<BaseRadio.Indicator className={\"lyds-radio__indicator\"} keepMounted />\n\t\t\t{children}\n\t\t</BaseRadio.Root>\n\t);\n}) as RadioComponent;\n\nexport interface RadioItemProps<Value = string> extends RadioProps<Value> {\n\tlabel: ReactNode;\n\tdescription?: ReactNode;\n\twrapperClassName?: string;\n}\n\ntype RadioItemComponent = <Value = string>(props: RadioItemProps<Value> & RefAttributes<HTMLElement>) => JSX.Element;\n\nexport const RadioItem = forwardRef(function RadioItem<Value = string>({ description, label, wrapperClassName, ...props }: RadioItemProps<Value>, ref: ForwardedRef<HTMLElement>) {\n\tconst { titleId, descriptionId } = useChoiceCopyIds(description);\n\n\treturn (\n\t\t<label className={cx(\"lyds-choice\", wrapperClassName)}>\n\t\t\t<Radio {...props} ref={ref} aria-labelledby={props[\"aria-labelledby\"] ?? titleId} aria-describedby={props[\"aria-describedby\"] ?? descriptionId} />\n\t\t\t<span className={\"lyds-choice__copy\"}>\n\t\t\t\t<span className={\"lyds-choice__title\"} id={titleId}>\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t\t{description ? (\n\t\t\t\t\t<span className={\"lyds-choice__description\"} id={descriptionId}>\n\t\t\t\t\t\t{description}\n\t\t\t\t\t</span>\n\t\t\t\t) : null}\n\t\t\t</span>\n\t\t</label>\n\t);\n}) as RadioItemComponent;\n\nexport interface SwitchProps extends SwitchRootProps {\n\tchildren?: ReactNode;\n}\n\nexport const Switch = forwardRef<HTMLElement, SwitchProps>(function Switch({ children, className, ...props }, ref) {\n\treturn (\n\t\t<BaseSwitch.Root {...props} className={withStateClassName(\"lyds-switch\", className)} ref={ref}>\n\t\t\t<span aria-hidden=\"true\" className={\"lyds-switch__signal\"} />\n\t\t\t<BaseSwitch.Thumb className={\"lyds-switch__thumb\"} />\n\t\t\t{children}\n\t\t</BaseSwitch.Root>\n\t);\n});\n\nexport interface SliderProps<Value extends number | readonly number[] = number> extends SliderRootProps<Value> {\n\tgetAriaLabel?: (index: number) => string;\n\tgetAriaValueText?: (formattedValue: string, value: number, index: number) => string;\n\tshowValue?: boolean;\n}\n\ntype SliderComponent = <Value extends number | readonly number[] = number>(props: SliderProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;\n\nfunction getThumbCount(value: number | readonly number[] | undefined): number {\n\treturn Array.isArray(value) ? Math.max(value.length, 1) : 1;\n}\n\nexport const Slider = forwardRef(function Slider<Value extends number | readonly number[] = number>(\n\t{\n\t\t\"aria-describedby\": ariaDescribedby,\n\t\t\"aria-label\": ariaLabel,\n\t\t\"aria-labelledby\": ariaLabelledby,\n\t\tclassName,\n\t\tdefaultValue,\n\t\tgetAriaLabel,\n\t\tgetAriaValueText,\n\t\tshowValue = false,\n\t\tvalue,\n\t\t...props\n\t}: SliderProps<Value>,\n\tref: ForwardedRef<HTMLDivElement>\n) {\n\tconst thumbCount = getThumbCount(value ?? defaultValue);\n\tconst fallbackThumbLabel = ariaLabel ? (index: number) => (thumbCount === 1 ? ariaLabel : `${ariaLabel} ${index + 1}`) : undefined;\n\t// Base UI owns the thumb inputs, so these two relationships have to be applied to the nodes it\n\t// renders. An inline callback would detach and reattach on every render; aria-labelledby is only\n\t// ever added because Base UI sets its own, while aria-describedby is ours to clear.\n\tconst applyThumbDescription = useCallback(\n\t\t(input: HTMLInputElement | null) => {\n\t\t\tif (!input) return;\n\t\t\tif (ariaDescribedby) input.setAttribute(\"aria-describedby\", ariaDescribedby);\n\t\t\telse input.removeAttribute(\"aria-describedby\");\n\t\t\tif (ariaLabelledby && !getAriaLabel) input.setAttribute(\"aria-labelledby\", ariaLabelledby);\n\t\t},\n\t\t[ariaDescribedby, ariaLabelledby, getAriaLabel]\n\t);\n\n\treturn (\n\t\t<BaseSlider.Root {...props} aria-label={ariaLabel} aria-labelledby={ariaLabelledby} className={withStateClassName(\"lyds-slider\", className)} defaultValue={defaultValue} ref={ref} value={value}>\n\t\t\t{showValue ? <BaseSlider.Value className={\"lyds-slider__value\"} /> : null}\n\t\t\t<BaseSlider.Control className={\"lyds-slider__control\"}>\n\t\t\t\t<BaseSlider.Track className={\"lyds-slider__track\"}>\n\t\t\t\t\t<BaseSlider.Indicator className={\"lyds-slider__indicator\"} />\n\t\t\t\t\t{Array.from({ length: thumbCount }, (_, index) => (\n\t\t\t\t\t\t<BaseSlider.Thumb\n\t\t\t\t\t\t\tclassName={\"lyds-slider__thumb\"}\n\t\t\t\t\t\t\tgetAriaLabel={getAriaLabel ?? fallbackThumbLabel}\n\t\t\t\t\t\t\tgetAriaValueText={getAriaValueText}\n\t\t\t\t\t\t\tinputRef={applyThumbDescription}\n\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\tkey={index}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</BaseSlider.Track>\n\t\t\t</BaseSlider.Control>\n\t\t</BaseSlider.Root>\n\t);\n}) as SliderComponent;\n\nexport interface ToggleProps<Value extends string = string> extends BaseToggleProps<Value> {\n\tvariant?: \"standard\" | \"quiet\";\n}\n\ntype ToggleComponent = <Value extends string = string>(props: ToggleProps<Value> & RefAttributes<HTMLButtonElement>) => JSX.Element;\n\nexport const Toggle = forwardRef(function Toggle<Value extends string = string>({ className, variant = \"standard\", ...props }: ToggleProps<Value>, ref: ForwardedRef<HTMLButtonElement>) {\n\treturn <BaseToggle {...props} className={state => cx(\"lyds-toggle\", variant === \"quiet\" && \"lyds-toggle--quiet\", typeof className === \"function\" ? className(state) : className)} ref={ref} />;\n}) as ToggleComponent;\n\nexport type ToggleGroupProps<Value extends string = string> = BaseToggleGroupProps<Value>;\n\ntype ToggleGroupComponent = <Value extends string = string>(props: ToggleGroupProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;\n\nexport const ToggleGroup = forwardRef(function ToggleGroup<Value extends string = string>({ className, ...props }: ToggleGroupProps<Value>, ref: ForwardedRef<HTMLDivElement>) {\n\treturn <BaseToggleGroup {...props} className={withStateClassName(\"lyds-toggle-group\", className)} ref={ref} />;\n}) as ToggleGroupComponent;\n\ninterface SegmentedControlOwnProps<Value extends string = string> extends Omit<\n\tBaseToggleGroupProps<Value>,\n\t\"aria-label\" | \"aria-labelledby\" | \"aria-readonly\" | \"defaultValue\" | \"multiple\" | \"onValueChange\" | \"value\"\n> {\n\tallowEmpty?: boolean;\n\tdefaultValue?: Value | null;\n\tname?: string;\n\tonValueChange?: (value: Value | null, details: BaseToggleGroup.ChangeEventDetails) => void;\n\tsize?: \"sm\" | \"md\";\n\tvalue?: Value | null;\n}\n\n/** The segments name themselves; the group they belong to does not, so it has to be told. */\nexport type SegmentedControlProps<Value extends string = string> = SegmentedControlOwnProps<Value> & AccessibleName;\n\ntype SegmentedControlComponent = <Value extends string = string>(props: SegmentedControlProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;\n\nexport const SegmentedControl = forwardRef(function SegmentedControl<Value extends string = string>(\n\t{\n\t\tallowEmpty = false,\n\t\t\"aria-label\": ariaLabel,\n\t\t\"aria-labelledby\": ariaLabelledby,\n\t\tclassName,\n\t\tdefaultValue = null,\n\t\tdisabled = false,\n\t\tname,\n\t\tonValueChange,\n\t\tsize = \"md\",\n\t\tvalue,\n\t\t...props\n\t}: SegmentedControlProps<Value>,\n\tref: ForwardedRef<HTMLDivElement>\n) {\n\tconst controlled = value !== undefined;\n\tconst [internalValue, setInternalValue] = useState<Value | null>(defaultValue);\n\tconst currentValue = controlled ? value : internalValue;\n\n\treturn (\n\t\t<>\n\t\t\t<BaseToggleGroup\n\t\t\t\t{...props}\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\taria-labelledby={ariaLabelledby}\n\t\t\t\tclassName={withStateClassName(\"lyds-segmented-control\", className)}\n\t\t\t\tdata-size={size}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tmultiple={false}\n\t\t\t\tonValueChange={(nextValues, details) => {\n\t\t\t\t\tconst nextValue = nextValues[0] ?? null;\n\t\t\t\t\tif (!allowEmpty && nextValue === null) return;\n\t\t\t\t\tonValueChange?.(nextValue, details);\n\t\t\t\t\tif (details.isCanceled) return;\n\t\t\t\t\tif (!controlled) setInternalValue(nextValue);\n\t\t\t\t}}\n\t\t\t\tref={ref}\n\t\t\t\tvalue={currentValue === null ? [] : [currentValue]}\n\t\t\t/>\n\t\t\t{name ? <input disabled={disabled} name={name} type=\"hidden\" value={currentValue ?? \"\"} /> : null}\n\t\t</>\n\t);\n}) as SegmentedControlComponent;\n\nexport const SegmentedControlItem = Toggle;\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,EAAW,EAAE,mBAAgB,MAAsC;CAC3E,OAAuB,EAAhB,IAAiB,IAAiD,GAAlD;EAAW,eAAY;EAAO,QAAO;CAAQ,CAAiD;AACtH;AAMA,IAAa,IAAW,EAAuC,SAAkB,EAAE,aAAU,cAAW,cAAW,kBAAe,GAAG,KAAS,GAAK;CAClJ,OACC,kBAAC,EAAa,MAAd;EAAmB,GAAI;EAAO,WAAW,EAAmB,iBAAiB,CAAS;EAAkB;EAAoB;EAA5H,UAAA,CACC,kBAAC,EAAa,WAAd;GAAwB,WAAW;GAA4B,aAAA;GAC7D,UAAA,KAAa,kBAAC,GAAD,EAAY,eAAe,KAAiB,GAAQ,CAAA;EAC3C,CAAA,GACvB,CACiB;;AAErB,CAAC,GAIY,IAAgB,EAA+C,SAAuB,EAAE,cAAW,GAAG,KAAS,GAAK;CAChI,OAAO,kBAAC,GAAD;EAAmB,GAAI;EAAO,WAAW,EAAmB,qBAAqB,CAAS;EAAQ;CAAM,CAAA;AAChH,CAAC;AASD,SAAS,EAAiB,GAAwB;CACjD,IAAM,IAAK,EAAM;CACjB,OAAO;EAAE,SAAS,GAAG,EAAG;EAAS,eAAe,IAAc,GAAG,EAAG,gBAAgB,KAAA;CAAU;AAC/F;AAQA,IAAa,IAAe,EAA2C,SAAsB,E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