@cladd-ui/react 0.0.1 → 0.0.3
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/LICENSE +21 -0
- package/README.md +1 -1
- package/components/Backdrop.d.ts +8 -0
- package/components/Backdrop.d.ts.map +1 -0
- package/components/Backdrop.js +7 -0
- package/components/Backdrop.js.map +1 -0
- package/components/BlockTitle.d.ts +10 -0
- package/components/BlockTitle.d.ts.map +1 -0
- package/components/BlockTitle.js +7 -0
- package/components/BlockTitle.js.map +1 -0
- package/components/Button.d.ts +61 -0
- package/components/Button.d.ts.map +1 -0
- package/components/Button.js +83 -0
- package/components/Button.js.map +1 -0
- package/components/Checkbox.d.ts +57 -0
- package/components/Checkbox.d.ts.map +1 -0
- package/components/Checkbox.js +48 -0
- package/components/Checkbox.js.map +1 -0
- package/components/Chip.d.ts +47 -0
- package/components/Chip.d.ts.map +1 -0
- package/components/Chip.js +55 -0
- package/components/Chip.js.map +1 -0
- package/components/Dialog.d.ts +118 -0
- package/components/Dialog.d.ts.map +1 -0
- package/components/Dialog.js +178 -0
- package/components/Dialog.js.map +1 -0
- package/components/DialogsPortal.d.ts +2 -0
- package/components/DialogsPortal.d.ts.map +1 -0
- package/components/DialogsPortal.js +17 -0
- package/components/DialogsPortal.js.map +1 -0
- package/components/DialogsPortalContext.d.ts +49 -0
- package/components/DialogsPortalContext.d.ts.map +1 -0
- package/components/DialogsPortalContext.js +17 -0
- package/components/DialogsPortalContext.js.map +1 -0
- package/components/FocusableLayer.d.ts +25 -0
- package/components/FocusableLayer.d.ts.map +1 -0
- package/components/FocusableLayer.js +18 -0
- package/components/FocusableLayer.js.map +1 -0
- package/components/Input.d.ts +87 -0
- package/components/Input.d.ts.map +1 -0
- package/components/Input.js +93 -0
- package/components/Input.js.map +1 -0
- package/components/Link.d.ts +28 -0
- package/components/Link.d.ts.map +1 -0
- package/components/Link.js +21 -0
- package/components/Link.js.map +1 -0
- package/components/List.d.ts +8 -0
- package/components/List.d.ts.map +1 -0
- package/components/List.js +7 -0
- package/components/List.js.map +1 -0
- package/components/ListButton.d.ts +61 -0
- package/components/ListButton.d.ts.map +1 -0
- package/components/ListButton.js +9 -0
- package/components/ListButton.js.map +1 -0
- package/components/ListItem.d.ts +8 -0
- package/components/ListItem.d.ts.map +1 -0
- package/components/ListItem.js +7 -0
- package/components/ListItem.js.map +1 -0
- package/components/ListSeparator.d.ts +8 -0
- package/components/ListSeparator.d.ts.map +1 -0
- package/components/ListSeparator.js +7 -0
- package/components/ListSeparator.js.map +1 -0
- package/components/ModalController.d.ts +26 -0
- package/components/ModalController.d.ts.map +1 -0
- package/components/ModalController.js +52 -0
- package/components/ModalController.js.map +1 -0
- package/components/NumberField.d.ts +49 -0
- package/components/NumberField.d.ts.map +1 -0
- package/components/NumberField.js +34 -0
- package/components/NumberField.js.map +1 -0
- package/components/Popover.d.ts +137 -0
- package/components/Popover.d.ts.map +1 -0
- package/components/Popover.js +366 -0
- package/components/Popover.js.map +1 -0
- package/components/Popup.d.ts +120 -0
- package/components/Popup.d.ts.map +1 -0
- package/components/Popup.js +235 -0
- package/components/Popup.js.map +1 -0
- package/components/PopupContent.d.ts +19 -0
- package/components/PopupContent.d.ts.map +1 -0
- package/components/PopupContent.js +8 -0
- package/components/PopupContent.js.map +1 -0
- package/components/Preloader.d.ts +12 -0
- package/components/Preloader.d.ts.map +1 -0
- package/components/Preloader.js +30 -0
- package/components/Preloader.js.map +1 -0
- package/components/Radio.d.ts +53 -0
- package/components/Radio.d.ts.map +1 -0
- package/components/Radio.js +46 -0
- package/components/Radio.js.map +1 -0
- package/components/Range.d.ts +35 -0
- package/components/Range.d.ts.map +1 -0
- package/components/Range.js +76 -0
- package/components/Range.js.map +1 -0
- package/components/Searchbar.d.ts +29 -0
- package/components/Searchbar.d.ts.map +1 -0
- package/components/Searchbar.js +10 -0
- package/components/Searchbar.js.map +1 -0
- package/components/Segmented.d.ts +39 -0
- package/components/Segmented.d.ts.map +1 -0
- package/components/Segmented.js +26 -0
- package/components/Segmented.js.map +1 -0
- package/components/SegmentedButton.d.ts +13 -0
- package/components/SegmentedButton.d.ts.map +1 -0
- package/components/SegmentedButton.js +10 -0
- package/components/SegmentedButton.js.map +1 -0
- package/components/SegmentedContext.d.ts +36 -0
- package/components/SegmentedContext.d.ts.map +1 -0
- package/components/SegmentedContext.js +10 -0
- package/components/SegmentedContext.js.map +1 -0
- package/components/Select.d.ts +145 -0
- package/components/Select.d.ts.map +1 -0
- package/components/Select.js +316 -0
- package/components/Select.js.map +1 -0
- package/components/Surface.d.ts +67 -0
- package/components/Surface.d.ts.map +1 -0
- package/components/Surface.js +36 -0
- package/components/Surface.js.map +1 -0
- package/components/SurfaceContent.d.ts +8 -0
- package/components/SurfaceContent.d.ts.map +1 -0
- package/components/SurfaceContent.js +7 -0
- package/components/SurfaceContent.js.map +1 -0
- package/components/SurfaceContext.d.ts +19 -0
- package/components/SurfaceContext.d.ts.map +1 -0
- package/components/SurfaceContext.js +9 -0
- package/components/SurfaceContext.js.map +1 -0
- package/components/SurfaceCut.d.ts +33 -0
- package/components/SurfaceCut.d.ts.map +1 -0
- package/components/SurfaceCut.js +17 -0
- package/components/SurfaceCut.js.map +1 -0
- package/components/SurfaceCutContent.d.ts +16 -0
- package/components/SurfaceCutContent.d.ts.map +1 -0
- package/components/SurfaceCutContent.js +8 -0
- package/components/SurfaceCutContent.js.map +1 -0
- package/components/TextArea.d.ts +61 -0
- package/components/TextArea.d.ts.map +1 -0
- package/components/TextArea.js +102 -0
- package/components/TextArea.js.map +1 -0
- package/components/ThemeContext.d.ts +23 -0
- package/components/ThemeContext.d.ts.map +1 -0
- package/components/ThemeContext.js +18 -0
- package/components/ThemeContext.js.map +1 -0
- package/components/Toast.d.ts +89 -0
- package/components/Toast.d.ts.map +1 -0
- package/components/Toast.js +129 -0
- package/components/Toast.js.map +1 -0
- package/components/ToastsPortal.d.ts +2 -0
- package/components/ToastsPortal.d.ts.map +1 -0
- package/components/ToastsPortal.js +17 -0
- package/components/ToastsPortal.js.map +1 -0
- package/components/ToastsPortalContext.d.ts +45 -0
- package/components/ToastsPortalContext.d.ts.map +1 -0
- package/components/ToastsPortalContext.js +17 -0
- package/components/ToastsPortalContext.js.map +1 -0
- package/components/Toggle.d.ts +69 -0
- package/components/Toggle.d.ts.map +1 -0
- package/components/Toggle.js +48 -0
- package/components/Toggle.js.map +1 -0
- package/components/Tooltip.d.ts +48 -0
- package/components/Tooltip.d.ts.map +1 -0
- package/components/Tooltip.js +90 -0
- package/components/Tooltip.js.map +1 -0
- package/components/UIProvider.d.ts +16 -0
- package/components/UIProvider.d.ts.map +1 -0
- package/components/UIProvider.js +11 -0
- package/components/UIProvider.js.map +1 -0
- package/components/WithTooltip.d.ts +36 -0
- package/components/WithTooltip.d.ts.map +1 -0
- package/components/WithTooltip.js +138 -0
- package/components/WithTooltip.js.map +1 -0
- package/components/icons/CheckIcon.d.ts +2 -0
- package/components/icons/CheckIcon.d.ts.map +1 -0
- package/components/icons/CheckIcon.js +5 -0
- package/components/icons/CheckIcon.js.map +1 -0
- package/components/icons/CloseIcon.d.ts +2 -0
- package/components/icons/CloseIcon.d.ts.map +1 -0
- package/components/icons/CloseIcon.js +3 -0
- package/components/icons/CloseIcon.js.map +1 -0
- package/components/icons/DropdownIcon.d.ts +2 -0
- package/components/icons/DropdownIcon.d.ts.map +1 -0
- package/components/icons/DropdownIcon.js +3 -0
- package/components/icons/DropdownIcon.js.map +1 -0
- package/components/icons/SearchIcon.d.ts +2 -0
- package/components/icons/SearchIcon.d.ts.map +1 -0
- package/components/icons/SearchIcon.js +5 -0
- package/components/icons/SearchIcon.js.map +1 -0
- package/hooks/use-accent-color.d.ts +2 -0
- package/hooks/use-accent-color.d.ts.map +1 -0
- package/hooks/use-accent-color.js +6 -0
- package/hooks/use-accent-color.js.map +1 -0
- package/hooks/use-device.d.ts +14 -0
- package/hooks/use-device.d.ts.map +1 -0
- package/hooks/use-device.js +68 -0
- package/hooks/use-device.js.map +1 -0
- package/hooks/use-dialog.d.ts +8 -0
- package/hooks/use-dialog.d.ts.map +1 -0
- package/hooks/use-dialog.js +38 -0
- package/hooks/use-dialog.js.map +1 -0
- package/hooks/use-focus-trap.d.ts +9 -0
- package/hooks/use-focus-trap.d.ts.map +1 -0
- package/hooks/use-focus-trap.js +106 -0
- package/hooks/use-focus-trap.js.map +1 -0
- package/hooks/use-modal-utils.d.ts +17 -0
- package/hooks/use-modal-utils.d.ts.map +1 -0
- package/hooks/use-modal-utils.js +110 -0
- package/hooks/use-modal-utils.js.map +1 -0
- package/hooks/use-surface.d.ts +2 -0
- package/hooks/use-surface.d.ts.map +1 -0
- package/hooks/use-surface.js +6 -0
- package/hooks/use-surface.js.map +1 -0
- package/hooks/use-theme.d.ts +2 -0
- package/hooks/use-theme.d.ts.map +1 -0
- package/hooks/use-theme.js +6 -0
- package/hooks/use-theme.js.map +1 -0
- package/hooks/use-toast.d.ts +3 -0
- package/hooks/use-toast.d.ts.map +1 -0
- package/hooks/use-toast.js +21 -0
- package/hooks/use-toast.js.map +1 -0
- package/index.d.ts +42 -0
- package/index.d.ts.map +1 -0
- package/index.js +42 -0
- package/index.js.map +1 -0
- package/package.json +27 -9
- package/shared/cn.d.ts +3 -0
- package/shared/cn.d.ts.map +1 -0
- package/shared/cn.js +6 -0
- package/shared/cn.js.map +1 -0
- package/shared/next-tick.d.ts +2 -0
- package/shared/next-tick.d.ts.map +1 -0
- package/shared/next-tick.js +6 -0
- package/shared/next-tick.js.map +1 -0
- package/styles/colors.css +403 -0
- package/styles/popup.css +14 -0
- package/styles/preloader.css +71 -0
- package/styles/range.css +17 -0
- package/styles/safe-areas.css +192 -0
- package/types.d.ts +2 -0
- package/types.d.ts.map +1 -0
- package/types.js +2 -0
- package/types.js.map +1 -0
- package/ui.css +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cladd-ui
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode, Ref, HTMLAttributes } from 'react';
|
|
2
|
+
export interface BackdropProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
className?: string;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
ref?: Ref<HTMLDivElement>;
|
|
6
|
+
}
|
|
7
|
+
export declare const Backdrop: (props: BackdropProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=Backdrop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Backdrop.d.ts","sourceRoot":"","sources":["../../../src/components/Backdrop.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAIvD,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,cAAc,CAAC;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,4CAY5C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../shared/cn';
|
|
3
|
+
export const Backdrop = (props) => {
|
|
4
|
+
const { className = '', children, ref, ...rest } = props;
|
|
5
|
+
return (_jsx("div", { ref: ref, className: cn('backdrop fixed inset-0 z-50 bg-backdrop/90', className), ...rest, children: children }));
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=Backdrop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Backdrop.js","sourceRoot":"","sources":["../../../src/components/Backdrop.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAQlC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAE,EAAE;IAC/C,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAEzD,OAAO,CACL,cACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,4CAA4C,EAAE,SAAS,CAAC,KAClE,IAAI,YAEP,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode, Ref, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
interface BlockTitleOwnProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
ref?: Ref<HTMLDivElement>;
|
|
6
|
+
}
|
|
7
|
+
export type BlockTitleProps = BlockTitleOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof BlockTitleOwnProps>;
|
|
8
|
+
export declare const BlockTitle: (props: BlockTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=BlockTitle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockTitle.d.ts","sourceRoot":"","sources":["../../../src/components/BlockTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAIjE,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAC9C,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,MAAM,kBAAkB,CAAC,CAAC;AAElE,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,4CAehD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../shared/cn';
|
|
3
|
+
export const BlockTitle = (props) => {
|
|
4
|
+
const { children, className = '', ref, ...rest } = props;
|
|
5
|
+
return (_jsx("div", { ref: ref, className: cn('block-title flex items-end gap-4 text-xs font-medium text-on-surface-dark uppercase select-none', className), ...rest, children: children }));
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=BlockTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockTitle.js","sourceRoot":"","sources":["../../../src/components/BlockTitle.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAWlC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;IACnD,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAEzD,OAAO,CACL,cACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,iGAAiG,EACjG,SAAS,CACV,KACG,IAAI,YAEP,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ElementType, ReactNode, Ref, CSSProperties, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { Color } from '../types';
|
|
3
|
+
import { SurfaceVariant } from './Surface';
|
|
4
|
+
export type ButtonSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
5
|
+
type ButtonSurface = 'surface' | 'cut';
|
|
6
|
+
interface ButtonOwnProps<C extends ElementType = 'button'> {
|
|
7
|
+
/** Button content (label, icons, etc.). */
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
/** Extra classes for the button surface root. */
|
|
10
|
+
className?: string;
|
|
11
|
+
/** Visually dim the button (40% opacity) and disable pointer events. */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Block clicks while keeping the button visually enabled - useful for "selected" segmented buttons. */
|
|
14
|
+
readOnly?: boolean;
|
|
15
|
+
/** When `true`, applies fully rounded corners (`rounded-full`, or matching pill radius for `multiline`). Default size-specific corner radii are used when `false`. */
|
|
16
|
+
rounded?: boolean;
|
|
17
|
+
size?: ButtonSize;
|
|
18
|
+
/**
|
|
19
|
+
* Polymorphic element to render. Defaults to `'button'`. Pass `'a'` for links
|
|
20
|
+
* (cursor switches to pointer automatically), or any custom component to retain
|
|
21
|
+
* Button styling on a different DOM node. The component's own props become valid here.
|
|
22
|
+
*/
|
|
23
|
+
component?: C;
|
|
24
|
+
/** Underlying `Surface` variant - see `SurfaceVariant`. Defaults to `'gradient'`. */
|
|
25
|
+
variant?: SurfaceVariant;
|
|
26
|
+
/** Accent color token. Sets the button's `color-{name}` class - drives text and ring colors. */
|
|
27
|
+
color?: Color;
|
|
28
|
+
/** Render the surface outline ring. Defaults to `true`. */
|
|
29
|
+
outline?: boolean;
|
|
30
|
+
/** Extra classes for the inner content row. */
|
|
31
|
+
contentClassName?: string;
|
|
32
|
+
/** Native `style` forwarded to the surface root. */
|
|
33
|
+
style?: CSSProperties;
|
|
34
|
+
/** Force the focus ring on, regardless of actual keyboard focus. */
|
|
35
|
+
focused?: boolean;
|
|
36
|
+
/** Force the pressed visual state, regardless of pointer activity. */
|
|
37
|
+
pressed?: boolean;
|
|
38
|
+
/** Allow text to wrap onto multiple lines, switching height to `min-h-*` and using pill radii compatible with multi-line content. */
|
|
39
|
+
multiline?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Which surface primitive to wrap with:
|
|
42
|
+
* - `'surface'` (default) - uses `Surface` (standard tinted/outlined panel).
|
|
43
|
+
* - `'cut'` - uses `SurfaceCut` (inset/recessed look - for buttons that sit inside another surface).
|
|
44
|
+
*/
|
|
45
|
+
surface?: ButtonSurface;
|
|
46
|
+
/** Forwarded to the underlying surface. Defaults to `true`; suppressed automatically when `disabled` or `readOnly`. */
|
|
47
|
+
clickable?: boolean;
|
|
48
|
+
/** Forwarded to the underlying surface. Defaults to `true`; suppressed automatically when `disabled` or `readOnly`. */
|
|
49
|
+
hoverable?: boolean;
|
|
50
|
+
/** When `true` (default), renders a `FocusableLayer` ring on keyboard focus. Suppressed automatically when `disabled` or `readOnly`. */
|
|
51
|
+
focusable?: boolean;
|
|
52
|
+
/** Forwarded to the underlying `Surface` as `level` - see `SurfaceProps.level` for the relative-offset (`"+1"`/`"-1"`) syntax. */
|
|
53
|
+
surfaceLevel?: string | number;
|
|
54
|
+
/** Forwarded to the polymorphic root element. */
|
|
55
|
+
ref?: Ref<HTMLElement>;
|
|
56
|
+
}
|
|
57
|
+
export type ButtonProps<C extends ElementType = 'button'> = ButtonOwnProps<C> & Omit<ComponentPropsWithoutRef<C>, keyof ButtonOwnProps<C>>;
|
|
58
|
+
export declare const buttonIconSizes: Record<ButtonSize, string>;
|
|
59
|
+
export declare const Button: <C extends ElementType = "button">(props: ButtonProps<C>) => import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,GAAG,EACH,aAAa,EACb,wBAAwB,EACzB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAW,cAAc,EAAE,MAAM,WAAW,CAAC;AAGpD,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAC3D,KAAK,aAAa,GAAG,SAAS,GAAG,KAAK,CAAC;AAEvC,UAAU,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,QAAQ;IACvD,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wGAAwG;IACxG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sKAAsK;IACtK,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC;IACd,qFAAqF;IACrF,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,gGAAgG;IAChG,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,2DAA2D;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qIAAqI;IACrI,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,uHAAuH;IACvH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uHAAuH;IACvH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wIAAwI;IACxI,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kIAAkI;IAClI,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,iDAAiD;IACjD,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,GAAG,QAAQ,IAAI,cAAc,CAAC,CAAC,CAAC,GAC3E,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7D,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAMtD,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,WAAW,GAAG,QAAQ,EACrD,OAAO,WAAW,CAAC,CAAC,CAAC,4CAsJtB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, } from 'react';
|
|
3
|
+
import { cn } from '../shared/cn';
|
|
4
|
+
import { FocusableLayer } from './FocusableLayer';
|
|
5
|
+
import { Surface } from './Surface';
|
|
6
|
+
import { SurfaceCut } from './SurfaceCut';
|
|
7
|
+
export const buttonIconSizes = {
|
|
8
|
+
sm: '[&>svg]:size-4',
|
|
9
|
+
md: '[&>svg]:size-4',
|
|
10
|
+
lg: '[&>svg]:size-4',
|
|
11
|
+
xl: '[&>svg]:size-4',
|
|
12
|
+
'2xl': '[&>svg]:size-4',
|
|
13
|
+
};
|
|
14
|
+
export const Button = (props) => {
|
|
15
|
+
const elRef = useRef(null);
|
|
16
|
+
const { children, className = '', disabled = false, readOnly, rounded = false, size = 'md', component = 'button', color = '', outline = true, contentClassName = '', variant = 'gradient', style, focused = false, pressed, multiline, surface: propSurface = 'surface', clickable = true, hoverable = true, focusable = true, surfaceLevel, ref, ...rest } = props;
|
|
17
|
+
let surface = propSurface || 'surface';
|
|
18
|
+
const heights = {
|
|
19
|
+
sm: multiline ? 'min-h-[24px]' : 'h-6',
|
|
20
|
+
md: multiline ? 'min-h-[28px]' : 'h-7',
|
|
21
|
+
lg: multiline ? 'min-h-[32px]' : 'h-9',
|
|
22
|
+
xl: multiline ? 'min-h-[40px]' : 'h-10',
|
|
23
|
+
'2xl': multiline ? 'min-h-[48px]' : 'h-12',
|
|
24
|
+
};
|
|
25
|
+
const roundedFullMultiline = {
|
|
26
|
+
sm: 'rounded-[12px]',
|
|
27
|
+
md: 'rounded-[14px]',
|
|
28
|
+
lg: 'rounded-[16px]',
|
|
29
|
+
xl: 'rounded-[20px]',
|
|
30
|
+
'2xl': 'rounded-[24px]',
|
|
31
|
+
};
|
|
32
|
+
const roundedSizes = {
|
|
33
|
+
sm: 'rounded-md',
|
|
34
|
+
md: 'rounded-lg',
|
|
35
|
+
lg: 'rounded-[10px]',
|
|
36
|
+
xl: 'rounded-xl',
|
|
37
|
+
'2xl': 'rounded-2xl',
|
|
38
|
+
};
|
|
39
|
+
const focusRoundedSizes = {
|
|
40
|
+
sm: 'rounded-[12px]',
|
|
41
|
+
md: 'rounded-[14px]',
|
|
42
|
+
lg: 'rounded-[16px]',
|
|
43
|
+
xl: 'rounded-[18px]',
|
|
44
|
+
'2xl': 'rounded-[22px]',
|
|
45
|
+
};
|
|
46
|
+
const paddings = {
|
|
47
|
+
sm: 'px-2.5',
|
|
48
|
+
md: 'px-2.5',
|
|
49
|
+
lg: 'px-2.5',
|
|
50
|
+
xl: 'px-2.5',
|
|
51
|
+
'2xl': 'px-3.5',
|
|
52
|
+
};
|
|
53
|
+
const fontSizes = {
|
|
54
|
+
sm: 'text-xs',
|
|
55
|
+
md: 'text-xs',
|
|
56
|
+
lg: 'text-xs',
|
|
57
|
+
xl: 'text-xs',
|
|
58
|
+
'2xl': 'text-xs',
|
|
59
|
+
};
|
|
60
|
+
const isSurfaceCut = surface === 'cut';
|
|
61
|
+
const WrapComponent = isSurfaceCut ? SurfaceCut : Surface;
|
|
62
|
+
const isFill = variant === 'solid-fill' || variant === 'gradient-fill';
|
|
63
|
+
return (_jsx(WrapComponent, { component: component, className: cn(`button group/button inline-block appearance-none text-left font-semibold outline-0 select-none focus:ring-0 focus:outline-0`, color &&
|
|
64
|
+
color !== 'neutral' &&
|
|
65
|
+
cn(isFill ? 'text-on-primary' : 'text-primary'), color && color === 'neutral' && isFill && 'text-on-primary', fontSizes[size], heights[size], disabled && 'pointer-events-none', !disabled && component === 'a' ? 'cursor-pointer' : 'cursor-auto', rounded
|
|
66
|
+
? multiline
|
|
67
|
+
? roundedFullMultiline[size]
|
|
68
|
+
: 'rounded-full'
|
|
69
|
+
: roundedSizes[size], className), contentClassName: cn('flex w-full items-center justify-center gap-2 py-1 [&>svg]:shrink-0', multiline && heights[size], buttonIconSizes[size], disabled && 'opacity-40', paddings[size], contentClassName), pressed: pressed, tabIndex: disabled || readOnly ? -1 : undefined, variant: variant, outline: outline, clickable: clickable && !disabled && !readOnly, hoverable: hoverable && !disabled && !readOnly, disabled: disabled || readOnly, level: surfaceLevel,
|
|
70
|
+
// {...enabledDisabledProps}
|
|
71
|
+
ref: (el) => {
|
|
72
|
+
elRef.current = el;
|
|
73
|
+
if (ref && typeof ref === 'function') {
|
|
74
|
+
ref(el);
|
|
75
|
+
}
|
|
76
|
+
else if (ref) {
|
|
77
|
+
ref.current = el;
|
|
78
|
+
}
|
|
79
|
+
}, onContextMenuCapture: (e) => e.preventDefault(), color: color, style: style, beforeContent: focusable &&
|
|
80
|
+
!readOnly &&
|
|
81
|
+
!disabled && (_jsx(FocusableLayer, { group: "button", className: cn(!rounded && focusRoundedSizes[size], rounded && 'rounded-full') })), ...rest, children: children }));
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,GAMP,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA4D1C,MAAM,CAAC,MAAM,eAAe,GAA+B;IACzD,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,gBAAgB;IACpB,KAAK,EAAE,gBAAgB;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,KAAqB,EACrB,EAAE;IACF,MAAM,KAAK,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAC/C,MAAM,EACJ,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,OAAO,GAAG,KAAK,EACf,IAAI,GAAG,IAAI,EACX,SAAS,GAAG,QAAQ,EACpB,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,IAAI,EACd,gBAAgB,GAAG,EAAE,EACrB,OAAO,GAAG,UAAU,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import { Color } from '../types';
|
|
3
|
+
export type CheckboxSize = 'sm' | 'md';
|
|
4
|
+
interface CheckboxOwnProps<C extends ElementType = 'label'> {
|
|
5
|
+
/** Controlled checked state. Default `false`. */
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
/** Visually dim the checkbox and disable interaction. */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Block toggling without the disabled visual treatment - useful for "locked" states. */
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
/** Native `value` - submitted with the form when `checked`. */
|
|
12
|
+
value?: string;
|
|
13
|
+
/** Native `name` - used for form submission and to group radio-like checkboxes. */
|
|
14
|
+
name?: string;
|
|
15
|
+
size?: CheckboxSize;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
/** Fires when the user toggles the checkbox. First arg is the new checked state, second is the raw event (when fired by the hidden `<input>`). */
|
|
18
|
+
onChange?: (checked: boolean, event?: ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
+
onClick?: (e: MouseEvent) => void;
|
|
20
|
+
onPointerDown?: (e: PointerEvent) => void;
|
|
21
|
+
/**
|
|
22
|
+
* When `true` (default), renders a hidden native `<input type="checkbox">` for form submission
|
|
23
|
+
* and accessibility. When `false`, the component falls back to ARIA roles (`role="checkbox"`,
|
|
24
|
+
* `aria-checked`, keyboard `Space`/`Enter` toggling) and `onChange` is fired from the click
|
|
25
|
+
* handler - useful for non-form contexts (e.g. menu items) or custom controlled wrappers.
|
|
26
|
+
*/
|
|
27
|
+
input?: boolean;
|
|
28
|
+
/** `id` for the hidden `<input>`. Used to wire an external `<label htmlFor>` to this checkbox. */
|
|
29
|
+
inputId?: string;
|
|
30
|
+
/** Extra classes for the outer label/element. */
|
|
31
|
+
className?: string;
|
|
32
|
+
/** Extra classes for the inner check icon (e.g. to override its color or size). */
|
|
33
|
+
checkClassName?: string;
|
|
34
|
+
/** Accent color for the checked state. Default: theme accent. */
|
|
35
|
+
color?: Color;
|
|
36
|
+
/**
|
|
37
|
+
* Polymorphic root element. Defaults to `'label'` so a wrapping `<label>` activates the hidden
|
|
38
|
+
* input on click. Use `'div'`/`'span'` (etc.) when the checkbox lives inside an existing label
|
|
39
|
+
* or needs a non-label container - see `hoverable`/`focusable` for how this changes interactivity.
|
|
40
|
+
*/
|
|
41
|
+
component?: C;
|
|
42
|
+
/**
|
|
43
|
+
* Auto-computed when omitted: `true` if `component === 'label'`, otherwise `false`.
|
|
44
|
+
* Override explicitly for custom containers that should still show hover affordances.
|
|
45
|
+
*/
|
|
46
|
+
hoverable?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Auto-computed when omitted: `true` if `component === 'label'` OR `input` is `true`.
|
|
49
|
+
* Drives whether the focus ring (`FocusableLayer`) is rendered. Override for non-label,
|
|
50
|
+
* input-less containers that still need a visible keyboard focus state.
|
|
51
|
+
*/
|
|
52
|
+
focusable?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export type CheckboxProps<C extends ElementType = 'label'> = CheckboxOwnProps<C> & Omit<ComponentPropsWithoutRef<C>, keyof CheckboxOwnProps<C>>;
|
|
55
|
+
export declare function Checkbox<C extends ElementType = 'label'>(props: CheckboxProps<C>): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,WAAW,EACX,UAAU,EACV,YAAY,EACZ,wBAAwB,EACzB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAKjC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC;AAEvC,UAAU,gBAAgB,CAAC,CAAC,SAAS,WAAW,GAAG,OAAO;IACxD,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yDAAyD;IACzD,Q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|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, } from 'react';
|
|
3
|
+
import { useAccentColor } from '../hooks/use-accent-color';
|
|
4
|
+
import { cn } from '../shared/cn';
|
|
5
|
+
import { FocusableLayer } from './FocusableLayer';
|
|
6
|
+
import { CheckIcon } from './icons/CheckIcon';
|
|
7
|
+
import { Surface } from './Surface';
|
|
8
|
+
export function Checkbox(props) {
|
|
9
|
+
const accentColor = useAccentColor();
|
|
10
|
+
const { checked = false, disabled = false, readOnly, value, name, size = 'sm', required = false, onChange = () => { }, onClick = () => { }, onPointerDown = () => { }, input = true, inputId, className, checkClassName, color = accentColor, component = 'label', hoverable, focusable, ...rest } = props;
|
|
11
|
+
const elRef = useRef(null);
|
|
12
|
+
let hoverableComputed = hoverable;
|
|
13
|
+
let focusableComputed = focusable;
|
|
14
|
+
if (typeof hoverableComputed === 'undefined')
|
|
15
|
+
hoverableComputed = component === 'label';
|
|
16
|
+
if (typeof focusableComputed === 'undefined')
|
|
17
|
+
focusableComputed = component === 'label' || input;
|
|
18
|
+
const Component = component;
|
|
19
|
+
const ariaFallback = !input
|
|
20
|
+
? {
|
|
21
|
+
role: 'checkbox',
|
|
22
|
+
'aria-checked': checked,
|
|
23
|
+
'aria-disabled': disabled || undefined,
|
|
24
|
+
'aria-readonly': readOnly || undefined,
|
|
25
|
+
'aria-required': required || undefined,
|
|
26
|
+
tabIndex: disabled ? -1 : 0,
|
|
27
|
+
onKeyDown: (e) => {
|
|
28
|
+
if (disabled || readOnly)
|
|
29
|
+
return;
|
|
30
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
onChange(!checked);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
: {};
|
|
37
|
+
const handleClick = (e) => {
|
|
38
|
+
onClick(e);
|
|
39
|
+
if (!input && !disabled && !readOnly) {
|
|
40
|
+
onChange(!checked);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return (_jsxs(Component, { className: cn('checkbox group/checkbox relative flex shrink-0 items-center justify-center rounded-full p-1 select-none', size === 'sm' && 'size-5', size === 'md' && 'size-6', disabled && 'opacity-50', className), onContextMenuCapture: (e) => e.preventDefault(), onClick: handleClick, onPointerDown: onPointerDown, ref: elRef, ...ariaFallback, ...rest, children: [input && (_jsx("input", { id: inputId, disabled: disabled || readOnly, readOnly: readOnly, checked: checked, required: required, type: "checkbox", value: value, name: name, className: "pointer-events-none absolute inset-1 z-10 opacity-0", onChange: (e) => onChange(!checked, e) })), _jsx(Surface, { className: cn('absolute inset-0 size-full shrink-0 rounded-full duration-200'), outline: true, variant: 'gradient', hoverable: hoverableComputed && !disabled && !readOnly, clickable: hoverableComputed && !disabled && !readOnly }), _jsx(Surface, { className: cn('absolute inset-0 size-full shrink-0 rounded-full duration-200', !checked && 'scale-0', checked ? 'opacity-100' : 'opacity-0'), color: color, outline: true, variant: 'gradient-fill', hoverable: hoverableComputed && !disabled && !readOnly, clickable: hoverableComputed && !disabled && !readOnly }), _jsx(CheckIcon, { className: cn('pointer-events-none relative duration-200', size === 'sm' && 'size-3', size === 'md' && 'size-4', !checked && 'scale-75 text-on-surface-dark', checked && !disabled && !readOnly && 'group-active/checkbox:scale-90', !checked &&
|
|
44
|
+
!disabled &&
|
|
45
|
+
!readOnly &&
|
|
46
|
+
'group-group-active/checkbox:scale-65', checked && cn('text-on-primary', `color-${color}`), checkClassName) }), focusableComputed && !disabled && !readOnly && (_jsx(FocusableLayer, { className: "rounded-full", group: "checkbox" }))] }));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,GAMP,MAAM,OAAO,CAAC;AA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QAAQ,IAAI,CAC9C,KAAC,cAAc,IAAC,SAAS,EAAC,cAAc,EAAC,KAAK,EAAC,UAAU,GAAG,CAC7D,IACS,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ReactNode, Ref, ElementType, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { Color } from '../types';
|
|
3
|
+
export type ChipSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
4
|
+
interface ChipOwnProps<C extends ElementType = 'span'> {
|
|
5
|
+
/** Chip content - typically a short label, optionally with an icon. */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/** Currently unused in styling - reserved for future "disabled chip" state. */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Extra classes for the chip surface root. */
|
|
10
|
+
className?: string;
|
|
11
|
+
/** Extra classes for the inner content row. */
|
|
12
|
+
contentClassName?: string;
|
|
13
|
+
/** Apply `rounded-full` (pill) corners. When `false` (default), uses size-specific corner radii. */
|
|
14
|
+
rounded?: boolean;
|
|
15
|
+
size?: ChipSize;
|
|
16
|
+
/**
|
|
17
|
+
* Polymorphic root element. Defaults to `'span'`. When set to `'a'` or `'button'`, the chip
|
|
18
|
+
* becomes interactive automatically (see `clickable`).
|
|
19
|
+
*/
|
|
20
|
+
component?: C;
|
|
21
|
+
/**
|
|
22
|
+
* Render an outline ring. When `true`, also forces the underlying surface variant to
|
|
23
|
+
* `'transparent'`; when `false`/omitted, the surface is `'gradient'`.
|
|
24
|
+
*/
|
|
25
|
+
outline?: boolean;
|
|
26
|
+
/** Show hover affordance. Implicitly enabled when the chip is clickable. */
|
|
27
|
+
hoverable?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Make the chip react to pointer activity (active/pressed state, hover overlay).
|
|
30
|
+
* Auto-computed when omitted: `true` if `component === 'a'` or `'button'`, otherwise `false`.
|
|
31
|
+
* Set explicitly to override (e.g. force a `<span>` to be clickable, or suppress the
|
|
32
|
+
* default for an `<a>` used purely as a navigation anchor).
|
|
33
|
+
*/
|
|
34
|
+
clickable?: boolean;
|
|
35
|
+
/** Accent color token. Sets the chip's `color-{name}` class - drives text and ring colors. */
|
|
36
|
+
color?: Color;
|
|
37
|
+
/** Icon component rendered before `children`. Receives `iconProps`. */
|
|
38
|
+
icon?: ElementType<any>;
|
|
39
|
+
/** Props forwarded to the `icon` component. */
|
|
40
|
+
iconProps?: Record<string, unknown>;
|
|
41
|
+
/** Forwarded to the polymorphic root element. */
|
|
42
|
+
ref?: Ref<HTMLElement>;
|
|
43
|
+
}
|
|
44
|
+
export type ChipProps<C extends ElementType = 'span'> = ChipOwnProps<C> & Omit<ComponentPropsWithoutRef<C>, keyof ChipOwnProps<C>>;
|
|
45
|
+
export declare const Chip: <C extends ElementType = "span">(props: ChipProps<C>) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=Chip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../src/components/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,GAAG,EACH,WAAW,EAEX,wBAAwB,EACzB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjC,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAEzD,UAAU,YAAY,CAAC,CAAC,SAAS,WAAW,GAAG,MAAM;IACnD,uEAAuE;IACvE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oGAAoG;IACpG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IACxB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,iDAAiD;IACjD,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,WAAW,GAAG,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,GACrE,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,WAAW,GAAG,MAAM,EAAE,OAAO,SAAS,CAAC,CAAC,CAAC,4CAoGvE,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, } from 'react';
|
|
3
|
+
import { cn } from '../shared/cn';
|
|
4
|
+
import { Surface } from './Surface';
|
|
5
|
+
export const Chip = (props) => {
|
|
6
|
+
const elRef = useRef(null);
|
|
7
|
+
const { children, disabled, className = '', contentClassName = '', rounded = false, size = 'md', component = 'span', outline, hoverable, clickable, color = '', icon: IconComponent, iconProps = {}, ref, ...rest } = props;
|
|
8
|
+
const heights = {
|
|
9
|
+
sm: 'h-4',
|
|
10
|
+
md: 'h-5',
|
|
11
|
+
lg: 'h-7',
|
|
12
|
+
xl: 'h-8',
|
|
13
|
+
'2xl': 'h-10',
|
|
14
|
+
};
|
|
15
|
+
const paddings = {
|
|
16
|
+
sm: 'px-2 [&:has(>svg)]:pl-1',
|
|
17
|
+
md: 'px-2 [&:has(>svg)]:pl-1',
|
|
18
|
+
lg: 'px-2.5 [&:has(>svg)]:pl-1.5',
|
|
19
|
+
xl: 'px-1.5',
|
|
20
|
+
'2xl': 'px-2',
|
|
21
|
+
};
|
|
22
|
+
const fontSizes = {
|
|
23
|
+
sm: 'text-[10px]',
|
|
24
|
+
md: 'text-[10px]',
|
|
25
|
+
lg: 'text-xs',
|
|
26
|
+
xl: 'text-sm',
|
|
27
|
+
'2xl': 'text-sm',
|
|
28
|
+
};
|
|
29
|
+
const iconSizes = {
|
|
30
|
+
sm: '[&>svg]:size-3',
|
|
31
|
+
md: '[&>svg]:size-4',
|
|
32
|
+
lg: '[&>svg]:size-4',
|
|
33
|
+
xl: '[&>svg]:size-4',
|
|
34
|
+
'2xl': '[&>svg]:size-4',
|
|
35
|
+
};
|
|
36
|
+
const roundedClasses = {
|
|
37
|
+
sm: 'rounded-[5px]',
|
|
38
|
+
md: 'rounded-md',
|
|
39
|
+
lg: 'rounded-lg',
|
|
40
|
+
xl: 'rounded-lg',
|
|
41
|
+
'2xl': 'rounded-lg',
|
|
42
|
+
};
|
|
43
|
+
let clickableComputed = clickable === true ||
|
|
44
|
+
(typeof clickable === 'undefined' &&
|
|
45
|
+
(component === 'a' || component === 'button'));
|
|
46
|
+
const SurfaceComponent = Surface;
|
|
47
|
+
return (_jsxs(SurfaceComponent, { component: component, hoverable: hoverable || clickableComputed, clickable: clickableComputed, outline: outline, variant: outline ? 'transparent' : 'gradient', contentClassName: cn('relative flex items-center justify-center gap-1 overflow-hidden text-ellipsis whitespace-nowrap [&>svg]:shrink-0', iconSizes[size], paddings[size], contentClassName), className: cn(`chip group/chip relative inline-flex font-semibold text-primary select-none focus:ring-0 focus:outline-0 focus:outline-none`, rounded ? 'rounded-full' : roundedClasses[size], clickableComputed && 'duration-200', clickableComputed && component === 'a'
|
|
48
|
+
? 'cursor-pointer'
|
|
49
|
+
: 'cursor-auto', heights[size], fontSizes[size], color && `color-${color}`, className), ref: (el) => {
|
|
50
|
+
elRef.current = el;
|
|
51
|
+
if (ref)
|
|
52
|
+
ref.current = el;
|
|
53
|
+
}, onContextMenuCapture: (e) => e.preventDefault(), ...rest, children: [IconComponent && _jsx(IconComponent, { ...(iconProps || {}) }), children] }));
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=Chip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../src/components/Chip.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,GAMP,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgDpC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAiC,KAAmB,EAAE,EAAE;IAC1E,MAAM,KAAK,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAC/C,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,gBAAgB,GAAG,EAAE,EACrB,OAAO,GAAG,KAAK,EACf,IAAI,GAAG,IAAI,EACX,SAAS,GAAG,MAAM,EAClB,OAAO,EACP,SAAS,EACT,SAAS,EACT,KAAK,GAAG,EAAE,EACV,IAAI,EAAE,aAAa,EACnB,SAAS,GAAG,EAAE,EACd,GAAG,EACH,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IACV,MAAM,OAAO,GAA6B;QACxC,EAAE,EAAE,KAAK;QACT,EAAE,EAAE,KAAK;QACT,EAAE,EAAE,KAAK;QACT,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,MAAM;KACd,CAAC;IACF,MAAM,QAAQ,GAA6B;QACzC,EAAE,EAAE,yB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Ac,CAAC,IAAI,CAAC,EAC/C,iBAAiB,IAAI,cAAc,EACnC,iBAAiB,IAAI,SAAS,KAAK,GAAG;YACpC,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,aAAa,EACjB,OAAO,CAAC,IAAI,CAAC,EACb,SAAS,CAAC,IAAI,CAAC,EACf,KAAK,IAAI,SAAS,KAAK,EAAE,EACzB,SAAS,CACV,EACD,GAAG,EAAE,CAAC,EAAsB,EAAE,EAAE;YAC9B,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;YACnB,IAAI,GAAG;gBACJ,GAAkD,CAAC,OAAO,GAAG,EAAE,CAAC;QACrE,CAAC,EACD,oBAAoB,EAAE,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,KACvD,IAAI,aAEP,aAAa,IAAI,KAAC,aAAa,OAAK,CAAC,SAAS,IAAI,EAAE,CAAC,GAAI,EACzD,QAAQ,IACQ,CACpB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ReactNode, Ref } from 'react';
|
|
2
|
+
import { Color } from '../types';
|
|
3
|
+
import { SurfaceVariant } from './Surface';
|
|
4
|
+
/**
|
|
5
|
+
* State container for the `Dialog` + `DialogTrigger` + `Dialog` compound. Use when you want
|
|
6
|
+
* the trigger and the dialog to be siblings in JSX:
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <DialogRoot>
|
|
10
|
+
* <DialogTrigger><Button>Confirm</Button></DialogTrigger>
|
|
11
|
+
* <Dialog title="..." />
|
|
12
|
+
* </DialogRoot>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Skip this and pass `open`/`onOpenChange` directly to `<Dialog>` if you'd rather control state.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DialogRoot: ({ children, defaultOpen, open: openProp, onOpenChange, }: {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
/** Initial open state (uncontrolled). Default `false`. Ignored when `open` is provided. */
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
/** Controlled open state. When provided, internal state is bypassed. */
|
|
22
|
+
open?: boolean;
|
|
23
|
+
/** Fires whenever the open state should change (trigger click, outside click, escape, button press). */
|
|
24
|
+
onOpenChange?: (open: boolean) => void;
|
|
25
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* Wraps a single child element to act as the dialog trigger. **Clones** the child to attach
|
|
28
|
+
* an `onClick` handler that toggles the surrounding `DialogRoot`'s open state (composed with
|
|
29
|
+
* any existing `onClick` on the child).
|
|
30
|
+
*
|
|
31
|
+
* No-ops (renders the child as-is) when used outside a `DialogRoot`. Unlike `PopoverTrigger`,
|
|
32
|
+
* this does **not** register an anchor ref - dialogs are centered on the viewport, not anchored.
|
|
33
|
+
*/
|
|
34
|
+
export declare const DialogTrigger: ({ children }: {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* Wraps a single child element to close the surrounding dialog when clicked. **Clones** the
|
|
39
|
+
* child to attach an `onClick` handler that flips the surrounding `DialogRoot`'s open state
|
|
40
|
+
* to `false` (composed with any existing `onClick` on the child).
|
|
41
|
+
*
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <DialogRoot>
|
|
44
|
+
* <DialogTrigger><Button>Open</Button></DialogTrigger>
|
|
45
|
+
* <Dialog title="...">
|
|
46
|
+
* ...
|
|
47
|
+
* <DialogClose><Button>Dismiss</Button></DialogClose>
|
|
48
|
+
* </Dialog>
|
|
49
|
+
* </DialogRoot>
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* No-ops (renders the child as-is) when used outside a `DialogRoot`.
|
|
53
|
+
*/
|
|
54
|
+
export declare const DialogClose: ({ children }: {
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export interface DialogProps {
|
|
58
|
+
/** Controlled open state. When omitted, falls back to the surrounding `DialogRoot` state, then `false`. */
|
|
59
|
+
open?: boolean;
|
|
60
|
+
/** Fires whenever the open state should change. When omitted, falls back to the `DialogRoot` setter. */
|
|
61
|
+
onOpenChange?: (open: boolean) => void;
|
|
62
|
+
/** Portal target selector. Default `'#app, #__next, #root'` (first match wins). */
|
|
63
|
+
root?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Selector for the container made `inert` while the dialog is open. Default `'.app-container'`.
|
|
66
|
+
* Used to block focus/interaction with the rest of the app while the modal is shown.
|
|
67
|
+
*/
|
|
68
|
+
inertContainer?: string;
|
|
69
|
+
/** Fires after the close transition completes - use for unmount or post-dismiss cleanup. */
|
|
70
|
+
onClosed?: () => void;
|
|
71
|
+
/** Extra classes applied to the dialog root `Surface`. */
|
|
72
|
+
className?: string;
|
|
73
|
+
/** Extra classes applied to the inner content area. Default includes `space-y-4 p-4`. */
|
|
74
|
+
contentClassName?: string;
|
|
75
|
+
/** Title slot. Rendered as `<div>` with `text-base font-semibold`. Auto-wired to `aria-labelledby`. */
|
|
76
|
+
title?: ReactNode;
|
|
77
|
+
/** Body text slot. Rendered as `<div>` with `text-sm leading-relaxed`. Auto-wired to `aria-describedby`. */
|
|
78
|
+
text?: ReactNode;
|
|
79
|
+
/** Defer rendering until first opened, and unmount after close. */
|
|
80
|
+
lazy?: boolean;
|
|
81
|
+
/** Custom button row. Rendered after the auto-generated cancel/confirm buttons (if any). */
|
|
82
|
+
buttons?: ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* "Type to confirm" guard. When set, renders an `Input` and disables the confirm button until
|
|
85
|
+
* the user types this exact string - used for destructive actions (e.g. type the project name to delete).
|
|
86
|
+
*/
|
|
87
|
+
requireConfirmText?: string;
|
|
88
|
+
/** Stop click propagation on backdrop and surface. Useful when the dialog is rendered inside a clickable parent. */
|
|
89
|
+
stopPropagationOnClick?: boolean;
|
|
90
|
+
cancelButtonText?: ReactNode;
|
|
91
|
+
confirmButtonText?: ReactNode;
|
|
92
|
+
/** Color for the cancel button. Default `'neutral'`. */
|
|
93
|
+
cancelButtonColor?: Color;
|
|
94
|
+
/** Color for the confirm button. Default: theme accent color. */
|
|
95
|
+
confirmButtonColor?: Color;
|
|
96
|
+
/** Forwarded to the underlying `Surface` as `level`. Default `1`. */
|
|
97
|
+
surfaceLevel?: string | number;
|
|
98
|
+
/** Surface variant. Default depends on theme: `'solid'` for light, `'gradient'` for dark. */
|
|
99
|
+
variant?: SurfaceVariant;
|
|
100
|
+
/** Outline ring on the dialog surface. Default `true` for dark, `false` for light. */
|
|
101
|
+
outline?: boolean;
|
|
102
|
+
/** Fires after the cancel button is pressed (the dialog also closes). */
|
|
103
|
+
onCancel?: () => void;
|
|
104
|
+
/** Fires after the confirm button is pressed and the `requireConfirmText` guard (if any) is satisfied. */
|
|
105
|
+
onConfirm?: () => void;
|
|
106
|
+
/** Forwarded to the dialog surface root. */
|
|
107
|
+
ref?: Ref<HTMLDivElement>;
|
|
108
|
+
/** ARIA label fallback when no `aria-labelledby`/`title` is set. */
|
|
109
|
+
'aria-label'?: string;
|
|
110
|
+
/** Override the auto-wired label id. By default this is the `title` element's id. */
|
|
111
|
+
'aria-labelledby'?: string;
|
|
112
|
+
/** Override the auto-wired description id. By default this is the `text` element's id. */
|
|
113
|
+
'aria-describedby'?: string;
|
|
114
|
+
/** Custom content rendered between `text` and the optional confirm-input/buttons row. */
|
|
115
|
+
children?: ReactNode;
|
|
116
|
+
}
|
|
117
|
+
export declare const Dialog: ({ open, onOpenChange, ...rest }: DialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
118
|
+
//# sourceMappingURL=Dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,SAAS,EACT,GAAG,EAEJ,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,KAA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