@ostack.tech/ui 0.7.0 → 0.8.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.
Files changed (38) hide show
  1. package/dist/ostack-ui.css +2 -2
  2. package/dist/ostack-ui.css.map +1 -1
  3. package/dist/ostack-ui.js +233 -210
  4. package/dist/ostack-ui.js.map +1 -1
  5. package/dist/types/components/Alert/Alert.d.ts +1 -1
  6. package/dist/types/components/Alert/AlertTitle.d.ts +7 -3
  7. package/dist/types/components/AlertDialog/AlertDialogTitle.d.ts +7 -2
  8. package/dist/types/components/Button/Button.d.ts +8 -3
  9. package/dist/types/components/Calendar/Calendar.d.ts +2 -2
  10. package/dist/types/components/Card/CardTitle.d.ts +8 -11
  11. package/dist/types/components/CloseButton/CloseButton.d.ts +1 -1
  12. package/dist/types/components/DataTable/DataTablePagination.d.ts +2 -2
  13. package/dist/types/components/DataTable/DataTableSelectionTrigger.d.ts +1 -1
  14. package/dist/types/components/Dialog/DialogTitle.d.ts +7 -2
  15. package/dist/types/components/ErrorBoundary/ErrorBoundary.d.ts +1 -1
  16. package/dist/types/components/FeedbackPopover/FeedbackPopover.d.ts +1 -1
  17. package/dist/types/components/FieldGroup/FieldGroupTitle.d.ts +7 -10
  18. package/dist/types/components/Heading/Heading.d.ts +13 -6
  19. package/dist/types/components/IconButton/IconButton.d.ts +9 -4
  20. package/dist/types/components/Label/Label.d.ts +1 -1
  21. package/dist/types/components/Link/Link.d.ts +8 -3
  22. package/dist/types/components/MenuList/MenuListItem.d.ts +6 -4
  23. package/dist/types/components/Select/Select.d.ts +1 -1
  24. package/dist/types/components/Table/TableColumn.d.ts +2 -2
  25. package/dist/types/index.d.ts +1 -0
  26. package/dist/types/providers/AlertDialogProvider/AlertDialogProviderContext.d.ts +2 -2
  27. package/dist/types/utils/polymorphicTypes.d.ts +23 -0
  28. package/package.json +1 -1
  29. package/scss/components/ControlAddon/_ControlAddon.scss +3 -3
  30. package/scss/components/FieldGroup/_FieldGroup-variables.scss +3 -3
  31. package/scss/components/Select/_Select-variables.scss +1 -1
  32. package/scss/components/Select/_Select.scss +1 -1
  33. package/scss/scss/placeholders/popover/_popover.scss +10 -12
  34. package/scss/scss/utils/_breakpoints.scss +4 -5
  35. package/scss/scss/utils/_css-color-functions.scss +10 -6
  36. package/scss/scss/utils/_declare-var.scss +1 -1
  37. package/scss/scss/utils/_maybe-important.scss +1 -1
  38. package/scss/scss/utils/_spacing.scss +10 -5
@@ -69,7 +69,7 @@ export interface AlertProps extends ComponentPropsWithoutRef<"div"> {
69
69
  * ```tsx
70
70
  * import { Alert, AlertTitle } from "@ostack.tech/ui";
71
71
  *
72
- * function TermAndConditionsNotice {
72
+ * function TermsAndConditionsNotice {
73
73
  * return (
74
74
  * <Alert>
75
75
  * <AlertTitle>Notice</AlertTitle>
@@ -1,6 +1,10 @@
1
- import { ComponentPropsWithoutRef } from 'react';
1
+ import { PolymorphicComponent, PolymorphicProps } from '../../utils/polymorphicTypes.ts';
2
+ /** Element an alert title can be rendered as. */
3
+ export type AlertTitleAs = "div" | "span" | "h2" | "h3" | "h4" | "h5" | "h6";
2
4
  /** Properties of the alert title component. */
3
- export interface AlertTitleProps extends ComponentPropsWithoutRef<"div"> {
5
+ export type AlertTitleProps<TAs extends AlertTitleAs = "div"> = PolymorphicProps<AlertTitleAs, TAs, "div", AlertTitleOwnProps>;
6
+ /** Own properties of the alert title component. */
7
+ export interface AlertTitleOwnProps {
4
8
  /**
5
9
  * Change the component to the HTML tag or custom component of the only child.
6
10
  * This will merge the original component props with the props of the supplied
@@ -9,4 +13,4 @@ export interface AlertTitleProps extends ComponentPropsWithoutRef<"div"> {
9
13
  asChild?: boolean;
10
14
  }
11
15
  /** Title of the alert. */
12
- export declare const AlertTitle: import('react').ForwardRefExoticComponent<AlertTitleProps & import('react').RefAttributes<HTMLDivElement>>;
16
+ export declare const AlertTitle: PolymorphicComponent<AlertTitleAs, "div", AlertTitleOwnProps>;
@@ -1,7 +1,12 @@
1
1
  import { AlertDialog as AlertDialogPrimitive } from 'radix-ui';
2
2
  import { ComponentPropsWithoutRef } from 'react';
3
+ import { PolymorphicComponent, PolymorphicProps } from '../../utils/polymorphicTypes.ts';
4
+ /** Element an alert dialog title can be rendered as. */
5
+ export type AlertDialogTitleAs = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span";
3
6
  /** Properties of the alert dialog title component. */
4
- export interface AlertDialogTitleProps extends ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title> {
7
+ export type AlertDialogTitleProps<TAs extends AlertDialogTitleAs = "h2"> = PolymorphicProps<AlertDialogTitleAs, TAs, "h2", AlertDialogTitleOwnProps>;
8
+ /** Own properties of the alert dialog title component. */
9
+ export interface AlertDialogTitleOwnProps extends Pick<ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>, "asChild"> {
5
10
  }
6
11
  /** Accessible title to be announced when the alert dialog is opened. */
7
- export declare const AlertDialogTitle: import('react').ForwardRefExoticComponent<AlertDialogTitleProps & import('react').RefAttributes<HTMLHeadingElement>>;
12
+ export declare const AlertDialogTitle: PolymorphicComponent<AlertDialogTitleAs, "h2", AlertDialogTitleOwnProps>;
@@ -1,7 +1,10 @@
1
- import { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
1
+ import { ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
2
2
  import { AccentColor } from '../../utils/accent.ts';
3
+ import { PolymorphicComponent, PolymorphicProps } from '../../utils/polymorphicTypes.ts';
3
4
  import { Icon, IconProp } from '../Icon';
4
5
  import { Spinner } from '../Spinner';
6
+ /** Elements a button can be rendered as. */
7
+ export type ButtonAs = "button" | "a";
5
8
  /** Button variants. */
6
9
  export type ButtonVariant = "solid" | "subtle" | "outlined" | "ghost";
7
10
  /** Button colours. */
@@ -11,7 +14,9 @@ export type ButtonSize = "sm" | "md" | "lg" | "xl";
11
14
  /** Button's icon placement. */
12
15
  export type ButtonIconPlacement = "start" | "end";
13
16
  /** Properties of the button component. */
14
- export interface ButtonProps extends ComponentPropsWithoutRef<"button"> {
17
+ export type ButtonProps<TAs extends ButtonAs = "button"> = PolymorphicProps<ButtonAs, TAs, "button", ButtonOwnProps>;
18
+ /** Own properties of the button component. */
19
+ export interface ButtonOwnProps {
15
20
  /**
16
21
  * Change the component to the HTML tag or custom component of the only child.
17
22
  * This will merge the original component props with the props of the supplied
@@ -133,4 +138,4 @@ export interface ButtonProps extends ComponentPropsWithoutRef<"button"> {
133
138
  * }
134
139
  * ```
135
140
  */
136
- export declare const Button: import('react').ForwardRefExoticComponent<ButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
141
+ export declare const Button: PolymorphicComponent<ButtonAs, "button", ButtonOwnProps>;
@@ -26,9 +26,9 @@ export interface CalendarProps extends Omit<DayPickerProps, "mode" | "selected"
26
26
  /** Properties to pass to the caption element. */
27
27
  captionProps?: ComponentPropsWithRef<"div">;
28
28
  /** Properties to pass to the previous button component. */
29
- previousButtonProps?: ComponentPropsWithRef<typeof IconButton>;
29
+ previousButtonProps?: ComponentPropsWithRef<typeof IconButton<"button">>;
30
30
  /** Properties to pass to the next button component. */
31
- nextButtonProps?: ComponentPropsWithRef<typeof IconButton>;
31
+ nextButtonProps?: ComponentPropsWithRef<typeof IconButton<"button">>;
32
32
  /** Properties to pass to the month select component. */
33
33
  monthSelectProps?: Omit<ComponentPropsWithRef<typeof Select>, "multiple" | "defaultValue" | "value">;
34
34
  /** Properties to pass to the year select component. */
@@ -1,19 +1,16 @@
1
- import { ComponentPropsWithoutRef } from 'react';
2
- import { HeadingLevel } from '../Heading';
3
- /** Properties of the card title component. */
4
- export interface CardTitleProps extends ComponentPropsWithoutRef<"h2"> {
1
+ import { PolymorphicComponent, PolymorphicProps } from '../../utils/polymorphicTypes.ts';
2
+ /** Elements a card title can be rendered as. */
3
+ export type CardTitleAs = "div" | "span" | "h2" | "h3" | "h4" | "h5" | "h6";
4
+ /** Properties of the button component. */
5
+ export type CardTitleProps<TAs extends CardTitleAs = "div"> = PolymorphicProps<CardTitleAs, TAs, "div", CardTitleOwnProps>;
6
+ /** Own properties of the card title component. */
7
+ export interface CardTitleOwnProps {
5
8
  /**
6
9
  * Change the component to the HTML tag or custom component of the only child.
7
10
  * This will merge the original component props with the props of the supplied
8
11
  * element/component and change the underlying DOM node.
9
12
  */
10
13
  asChild?: boolean;
11
- /**
12
- * Heading level.
13
- *
14
- * @default 2
15
- */
16
- level?: HeadingLevel;
17
14
  }
18
15
  /** Title of the `Card` component. */
19
- export declare const CardTitle: import('react').ForwardRefExoticComponent<CardTitleProps & import('react').RefAttributes<HTMLHeadingElement>>;
16
+ export declare const CardTitle: PolymorphicComponent<CardTitleAs, "div", CardTitleOwnProps>;
@@ -1,7 +1,7 @@
1
1
  import { ComponentPropsWithoutRef } from 'react';
2
2
  import { IconButton } from '../IconButton';
3
3
  /** Properties of the close button component. */
4
- export interface CloseButtonProps extends Partial<ComponentPropsWithoutRef<typeof IconButton>> {
4
+ export interface CloseButtonProps extends Partial<ComponentPropsWithoutRef<typeof IconButton<"button">>> {
5
5
  }
6
6
  /** Component rendering a “close” button. */
7
7
  export declare const CloseButton: import('react').ForwardRefExoticComponent<CloseButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
@@ -25,9 +25,9 @@ export interface DataTablePaginationProps extends ComponentPropsWithoutRef<"div"
25
25
  * Properties to pass to the previous page button (only relevant in paged
26
26
  * mode).
27
27
  */
28
- previousPageButtonProps?: ComponentPropsWithRef<typeof IconButton>;
28
+ previousPageButtonProps?: ComponentPropsWithRef<typeof IconButton<"button">>;
29
29
  /** Properties to pass to the next page button (only relevant in paged mode). */
30
- nextPageButtonProps?: ComponentPropsWithRef<typeof IconButton>;
30
+ nextPageButtonProps?: ComponentPropsWithRef<typeof IconButton<"button">>;
31
31
  }
32
32
  /** Component used to provide pagination to the data table. */
33
33
  export declare const DataTablePagination: import('react').ForwardRefExoticComponent<DataTablePaginationProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,7 @@
1
1
  import { ComponentPropsWithoutRef, Key, MouseEvent, ReactNode } from 'react';
2
2
  import { Button } from '../Button';
3
3
  /** Properties of the data table selection trigger component. */
4
- export interface DataTableSelectionTriggerProps extends Omit<ComponentPropsWithoutRef<typeof Button>, "onClick"> {
4
+ export interface DataTableSelectionTriggerProps extends Omit<ComponentPropsWithoutRef<typeof Button<"button">>, "onClick"> {
5
5
  /**
6
6
  * Whether the component should preferably be aligned to the right. This only
7
7
  * has an effect when the component is nested directly under the `DataTable`.
@@ -1,7 +1,12 @@
1
1
  import { Dialog as DialogPrimitive } from 'radix-ui';
2
2
  import { ComponentPropsWithoutRef } from 'react';
3
+ import { PolymorphicComponent, PolymorphicProps } from '../../utils/polymorphicTypes.ts';
4
+ /** Element a dialog title can be rendered as. */
5
+ export type DialogTitleAs = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span";
3
6
  /** Properties of the dialog title component. */
4
- export interface DialogTitleProps extends ComponentPropsWithoutRef<typeof DialogPrimitive.Title> {
7
+ export type DialogTitleProps<TAs extends DialogTitleAs = "h2"> = PolymorphicProps<DialogTitleAs, TAs, "h2", DialogTitleOwnProps>;
8
+ /** Own properties of the dialog title component. */
9
+ export interface DialogTitleOwnProps extends Pick<ComponentPropsWithoutRef<typeof DialogPrimitive.Title>, "asChild"> {
5
10
  }
6
11
  /** Accessible title to be announced when the dialog is opened. */
7
- export declare const DialogTitle: import('react').ForwardRefExoticComponent<DialogTitleProps & import('react').RefAttributes<HTMLHeadingElement>>;
12
+ export declare const DialogTitle: PolymorphicComponent<DialogTitleAs, "h2", DialogTitleOwnProps>;
@@ -68,7 +68,7 @@ export interface ErrorBoundaryProps extends Pick<ComponentPropsWithoutRef<typeof
68
68
  * Properties to pass to the `IconButton` component used to reset the error
69
69
  * boundary.
70
70
  */
71
- resetButtonProps?: ComponentPropsWithRef<typeof IconButton>;
71
+ resetButtonProps?: ComponentPropsWithRef<typeof IconButton<"button">>;
72
72
  children?: ReactNode;
73
73
  }
74
74
  /**
@@ -25,7 +25,7 @@ export interface FeedbackPopoverProps extends ComponentPropsWithoutRef<typeof Po
25
25
  /** Properties to pass to the element containing the button. */
26
26
  buttonContainerProps?: ComponentPropsWithRef<"div">;
27
27
  /** Properties to pass to the `IconButton` component. */
28
- iconButtonProps?: Omit<ComponentPropsWithRef<typeof IconButton>, "size" | "icon" | "label">;
28
+ iconButtonProps?: Omit<ComponentPropsWithRef<typeof IconButton<"button">>, "size" | "icon" | "label">;
29
29
  }
30
30
  /**
31
31
  * Component used to provide feedback to a form control, where the feedback is
@@ -1,19 +1,16 @@
1
- import { ComponentPropsWithoutRef } from 'react';
2
- import { HeadingLevel } from '../Heading';
1
+ import { PolymorphicComponent, PolymorphicProps } from '../../utils/polymorphicTypes.ts';
2
+ /** Element a field group title can be rendered as. */
3
+ export type FieldGroupTitleAs = "div" | "span" | "label" | "h2" | "h3" | "h4" | "h5" | "h6";
3
4
  /** Properties of the field group title component. */
4
- export interface FieldGroupTitleProps extends ComponentPropsWithoutRef<"h2"> {
5
+ export type FieldGroupTitleProps<TAs extends FieldGroupTitleAs = "div"> = PolymorphicProps<FieldGroupTitleAs, TAs, "div", FieldGroupTitleOwnProps>;
6
+ /** Own properties of the field group title component. */
7
+ export interface FieldGroupTitleOwnProps {
5
8
  /**
6
9
  * Change the component to the HTML tag or custom component of the only child.
7
10
  * This will merge the original component props with the props of the supplied
8
11
  * element/component and change the underlying DOM node.
9
12
  */
10
13
  asChild?: boolean;
11
- /**
12
- * Heading level.
13
- *
14
- * @default 2
15
- */
16
- level?: HeadingLevel;
17
14
  }
18
15
  /** Component used to display the caption of a field group. */
19
- export declare const FieldGroupTitle: import('react').ForwardRefExoticComponent<FieldGroupTitleProps & import('react').RefAttributes<HTMLHeadingElement>>;
16
+ export declare const FieldGroupTitle: PolymorphicComponent<FieldGroupTitleAs, "div", FieldGroupTitleOwnProps>;
@@ -1,8 +1,12 @@
1
- import { ComponentPropsWithoutRef } from 'react';
1
+ import { PolymorphicComponent, PolymorphicProps } from '../../utils/polymorphicTypes.ts';
2
+ /** Elements a heading can be rendered as. */
3
+ export type HeadingAs = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span" | "label";
2
4
  /** Heading levels. */
3
5
  export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
4
6
  /** Properties of the heading component. */
5
- export interface HeadingProps extends ComponentPropsWithoutRef<`h${HeadingLevel}`> {
7
+ export type HeadingProps<TAs extends HeadingAs = "h2"> = PolymorphicProps<HeadingAs, TAs, "h2", HeadingOwnProps>;
8
+ /** Own properties of the heading component. */
9
+ export interface HeadingOwnProps {
6
10
  /**
7
11
  * Change the component to the HTML tag or custom component of the only child.
8
12
  * This will merge the original component props with the props of the supplied
@@ -10,9 +14,12 @@ export interface HeadingProps extends ComponentPropsWithoutRef<`h${HeadingLevel}
10
14
  */
11
15
  asChild?: boolean;
12
16
  /**
13
- * Heading level. By default, if `asChild` is not provided, the level is used
14
- * to determine which HTML element to render, so a level of `2` causes an
15
- * `<h2>` element to be rendered.
17
+ * Heading level, the larger the level, the smaller the font-size (level `1`
18
+ * is largest, `6` smallest).
19
+ *
20
+ * By default, if `as` and `asChild` are not provided, the level is used to
21
+ * determine which HTML element to render, so a level of `2` causes a `<h2>`
22
+ * element to be rendered.
16
23
  *
17
24
  * @default 2
18
25
  */
@@ -31,4 +38,4 @@ export interface HeadingProps extends ComponentPropsWithoutRef<`h${HeadingLevel}
31
38
  * }
32
39
  * ```
33
40
  */
34
- export declare const Heading: import('react').ForwardRefExoticComponent<HeadingProps & import('react').RefAttributes<HTMLHeadingElement>>;
41
+ export declare const Heading: PolymorphicComponent<HeadingAs, "h2", HeadingOwnProps>;
@@ -1,8 +1,11 @@
1
- import { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
2
- import { ButtonColor, ButtonSize, ButtonVariant } from '../Button';
1
+ import { ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
2
+ import { PolymorphicComponent, PolymorphicProps } from '../../utils/polymorphicTypes.ts';
3
+ import { ButtonAs, ButtonColor, ButtonSize, ButtonVariant } from '../Button';
3
4
  import { Icon, IconProp } from '../Icon';
4
5
  import { Spinner } from '../Spinner';
5
6
  import { Tooltip } from '../Tooltip';
7
+ /** Elements an icon button can be rendered as. */
8
+ export type IconButtonAs = ButtonAs;
6
9
  /** Icon button variants. */
7
10
  export type IconButtonVariant = ButtonVariant;
8
11
  /** Icon button colours. */
@@ -10,7 +13,9 @@ export type IconButtonColor = ButtonColor;
10
13
  /** Icon button sizes. */
11
14
  export type IconButtonSize = ButtonSize;
12
15
  /** Properties of the icon button component. */
13
- export interface IconButtonProps extends Omit<ComponentPropsWithoutRef<"button">, "children"> {
16
+ export type IconButtonProps<TAs extends IconButtonAs = "button"> = PolymorphicProps<IconButtonAs, TAs, "button", IconButtonOwnProps>;
17
+ /** Own properties of the icon button component. */
18
+ export interface IconButtonOwnProps {
14
19
  /**
15
20
  * Change the component to the HTML tag or custom component of the only child.
16
21
  * This will merge the original component props with the props of the supplied
@@ -144,4 +149,4 @@ export interface IconButtonProps extends Omit<ComponentPropsWithoutRef<"button">
144
149
  * }
145
150
  * ```
146
151
  */
147
- export declare const IconButton: import('react').ForwardRefExoticComponent<IconButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
152
+ export declare const IconButton: PolymorphicComponent<IconButtonAs, "button", IconButtonOwnProps>;
@@ -20,7 +20,7 @@ export interface LabelProps extends ComponentPropsWithoutRef<typeof LabelPrimiti
20
20
  /** Properties to pass to the required icon component. */
21
21
  requiredIconProps?: Omit<ComponentPropsWithRef<typeof Icon>, "icon">;
22
22
  /** Properties to pass to the helper button component. */
23
- helperButtonProps?: Omit<ComponentPropsWithRef<typeof IconButton>, "icon">;
23
+ helperButtonProps?: Omit<ComponentPropsWithRef<typeof IconButton<"button">>, "icon">;
24
24
  /** Properties to pass to the helper popover component. */
25
25
  helperPopoverProps?: ComponentPropsWithRef<typeof Popover>;
26
26
  /** Properties to pass to the helper popover content component. */
@@ -1,12 +1,17 @@
1
- import { ComponentPropsWithoutRef, ComponentPropsWithRef } from 'react';
1
+ import { ComponentPropsWithRef } from 'react';
2
2
  import { AccentColor } from '../../utils/accent.ts';
3
+ import { PolymorphicComponent, PolymorphicProps } from '../../utils/polymorphicTypes.ts';
3
4
  import { Icon, IconProp } from '../Icon';
5
+ /** Elements a link can be rendered as. */
6
+ export type LinkAs = "a" | "button";
4
7
  /** Link variants. */
5
8
  export type LinkVariant = "default" | "alert";
6
9
  /** Link colours. */
7
10
  export type LinkColor = AccentColor;
8
11
  /** Properties of the link component. */
9
- export interface LinkProps extends ComponentPropsWithoutRef<"a"> {
12
+ export type LinkProps<TAs extends LinkAs = "a"> = PolymorphicProps<LinkAs, TAs, "a", LinkOwnProps>;
13
+ /** Own properties of the link component. */
14
+ export interface LinkOwnProps {
10
15
  /**
11
16
  * Change the component to the HTML tag or custom component of the only child.
12
17
  * This will merge the original component props with the props of the supplied
@@ -55,4 +60,4 @@ export interface LinkProps extends ComponentPropsWithoutRef<"a"> {
55
60
  * }
56
61
  * ```
57
62
  */
58
- export declare const Link: import('react').ForwardRefExoticComponent<LinkProps & import('react').RefAttributes<HTMLAnchorElement>>;
63
+ export declare const Link: PolymorphicComponent<LinkAs, "a", LinkOwnProps>;
@@ -3,6 +3,8 @@ import { AccentColor } from '../../utils/accent.ts';
3
3
  import { Icon, IconProp } from '../Icon';
4
4
  import { Spinner } from '../Spinner';
5
5
  import { MenuListIconPlacement } from './MenuList.tsx';
6
+ /** Elements a menu list item's action can be rendered as. */
7
+ export type MenuListItemType = "button" | "link" | "text";
6
8
  /** Menu list item colours. */
7
9
  export type MenuListItemColor = AccentColor;
8
10
  /** Properties of the menu list item component. */
@@ -18,7 +20,7 @@ export interface MenuListItemProps extends Omit<ComponentPropsWithoutRef<"li">,
18
20
  *
19
21
  * @default button
20
22
  */
21
- type?: "button" | "link" | "text";
23
+ type?: MenuListItemType;
22
24
  /**
23
25
  * Marks the item as being selected.
24
26
  *
@@ -84,11 +86,11 @@ export interface MenuListItemProps extends Omit<ComponentPropsWithoutRef<"li">,
84
86
  * @default start
85
87
  */
86
88
  iconPlacement?: MenuListIconPlacement;
87
- /** Href for the link, when `itemType` is set to `"link"`. */
89
+ /** Href for the link, when `type` is set to `"link"`. */
88
90
  href?: ComponentProps<"a">["href"];
89
- /** Target of the link, when `itemType` is set to `"link"`. */
91
+ /** Target of the link, when `type` is set to `"link"`. */
90
92
  target?: ComponentProps<"a">["target"];
91
- /** Rel of the link, when `itemType` is set to `"link"`. */
93
+ /** Rel of the link, when `type` is set to `"link"`. */
92
94
  rel?: ComponentProps<"a">["rel"];
93
95
  /** Properties to pass to the action element of the item. */
94
96
  actionProps?: Omit<ComponentPropsWithRef<"button" | "a" | "div">, "disabled" | "href" | "target" | "rel">;
@@ -63,7 +63,7 @@ export interface SelectPropsBase<T extends string | number | readonly string[] =
63
63
  /** Properties to pass to each `Tag` holding a value, when `multiple` is set. */
64
64
  valueTagProps?: Omit<ComponentPropsWithoutRef<typeof Tag>, "defaultOpen" | "open" | "onOpenChange" | "color" | "showCloseButton">;
65
65
  /** Properties to pass to the arrow `Icon` component. */
66
- arrowProps?: Omit<ComponentPropsWithRef<typeof IconButton>, "icon" | "label">;
66
+ arrowProps?: Omit<ComponentPropsWithRef<typeof IconButton<"button">>, "icon" | "label">;
67
67
  /** Properties to pass to the `Popover` component. */
68
68
  popoverProps?: ComponentPropsWithRef<typeof PopoverContent>;
69
69
  /** Options to pass to the `CommandMenu` component. */
@@ -59,7 +59,7 @@ export interface TableColumnProps extends Omit<ComponentPropsWithoutRef<typeof T
59
59
  /** Properties to pass to the label component. */
60
60
  labelProps?: ComponentPropsWithRef<"div">;
61
61
  /** Properties to pass to the sort button. */
62
- sortButtonProps?: ComponentPropsWithRef<typeof Button>;
62
+ sortButtonProps?: ComponentPropsWithRef<typeof Button<"button">>;
63
63
  /** Properties to pass to the component containing the sort icons. */
64
64
  sortIconContainerProps?: ComponentPropsWithRef<"div">;
65
65
  /** Properties to pass to the sort ascending icon component. */
@@ -67,7 +67,7 @@ export interface TableColumnProps extends Omit<ComponentPropsWithoutRef<typeof T
67
67
  /** Properties to pass to the sort descending icon component. */
68
68
  sortDescIconProps?: ComponentPropsWithRef<typeof Icon>;
69
69
  /** Properties to pass to the helper button component. */
70
- helperButtonProps?: Omit<ComponentPropsWithRef<typeof IconButton>, "icon">;
70
+ helperButtonProps?: Omit<ComponentPropsWithRef<typeof IconButton<"button">>, "icon">;
71
71
  /** Properties to pass to the helper popover component. */
72
72
  helperPopoverProps?: ComponentPropsWithRef<typeof Popover>;
73
73
  /** Properties to pass to the helper popover content component. */
@@ -77,6 +77,7 @@ export * from './utils/nativeControls.ts';
77
77
  export * from './utils/navigate.ts';
78
78
  export * from './utils/numericStringUtils.ts';
79
79
  export * from './utils/parseDateStrict.ts';
80
+ export * from './utils/polymorphicTypes.ts';
80
81
  export * from './utils/setNativeProperty.ts';
81
82
  export * from './utils/sorting.ts';
82
83
  export * from './utils/stringHash.ts';
@@ -49,14 +49,14 @@ export interface AlertDialogOptions {
49
49
  /** Properties to pass to the alert dialog's footer component. */
50
50
  footerProps?: ComponentPropsWithRef<typeof AlertDialogFooter>;
51
51
  /** Properties to pass to the alert dialog's OK button component. */
52
- okButtonProps?: Omit<ComponentPropsWithRef<typeof Button>, "onClick">;
52
+ okButtonProps?: Omit<ComponentPropsWithRef<typeof Button<"button">>, "onClick">;
53
53
  }
54
54
  /** Options that can be provided to a `confirm` alert dialog. */
55
55
  export interface ConfirmDialogOptions extends AlertDialogOptions {
56
56
  /** Alert dialog's cancel text. */
57
57
  cancelText?: ReactNode;
58
58
  /** Properties to pass to the alert dialog's cancel button component. */
59
- cancelButtonProps?: Omit<ComponentPropsWithRef<typeof Button>, "onClick">;
59
+ cancelButtonProps?: Omit<ComponentPropsWithRef<typeof Button<"button">>, "onClick">;
60
60
  }
61
61
  /** Value of the alert dialog context. */
62
62
  export interface AlertDialogProviderContextValue {
@@ -0,0 +1,23 @@
1
+ import { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, ReactElement } from 'react';
2
+ /** Properties of a polymorphic component. */
3
+ export type PolymorphicProps<TAsAllowed extends ElementType, TAs extends TAsAllowed, TAsDefault extends TAsAllowed, TOwnProps> = TOwnProps & AsProp<TAsAllowed, TAs, TAsDefault> & Omit<ComponentPropsWithoutRef<TAs>, keyof TOwnProps | "as">;
4
+ /** Reference type for a polymorphic component. */
5
+ export type PolymorphicRef<TAs extends ElementType> = ComponentPropsWithRef<TAs>["ref"];
6
+ /** Polymorphic component type supporting an `as` property. */
7
+ export interface PolymorphicComponent<TAsAllowed extends ElementType, TAsDefault extends TAsAllowed, TOwnProps> {
8
+ (props: PolymorphicProps<TAsAllowed, TAsDefault, TAsDefault, TOwnProps> & {
9
+ ref?: PolymorphicRef<TAsDefault>;
10
+ }): ReactElement | null;
11
+ <TAs extends TAsAllowed>(props: PolymorphicProps<TAsAllowed, TAs, TAsDefault, TOwnProps> & {
12
+ ref?: PolymorphicRef<TAs>;
13
+ }): ReactElement | null;
14
+ }
15
+ /** `as` property for polymorphic components. */
16
+ type AsProp<TAsAllowed extends ElementType, TAs extends TAsAllowed, TAsDefault extends TAsAllowed> = TAsDefault extends TAs ? {
17
+ /** Element to render the component as. */
18
+ as?: TAs;
19
+ } : {
20
+ /** Element to render the component as. */
21
+ as: TAs;
22
+ };
23
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ostack.tech/ui",
3
3
  "description": "ostack/UI component library.",
4
- "version": "0.7.0",
4
+ "version": "0.8.0",
5
5
  "homepage": "https://ui.ostack.tech/",
6
6
  "author": {
7
7
  "name": "Opensoft",
@@ -121,9 +121,9 @@
121
121
  & > .#{$prefix}icon {
122
122
  font-size: $control-addon-icon-font-size;
123
123
  filter: if(
124
- $control-addon-text-shadow != null,
125
- drop-shadow($control-addon-text-shadow),
126
- null
124
+ sass($control-addon-text-shadow != null): drop-shadow(
125
+ $control-addon-text-shadow
126
+ )
127
127
  );
128
128
  }
129
129
 
@@ -13,10 +13,10 @@ $field-group-code-width: $control-code-width !default;
13
13
  $field-group-code-padding-y: spacing(1) !default;
14
14
  $field-group-code-padding-x: spacing(0.5) !default;
15
15
  $field-group-code-margin-x: spacing(2) !default;
16
- $field-group-code-font-size: var(--#{$prefix}font-size-sm) !default;
17
- $field-group-code-line-height: var(--#{$prefix}line-height-sm) !default;
16
+ $field-group-code-font-size: $control-code-font-size !default;
17
+ $field-group-code-line-height: $control-code-line-height !default;
18
18
  $field-group-code-font-weight: $font-weight-semibold !default;
19
- $field-group-code-border-radius: var(--#{$prefix}border-radius-sm) !default;
19
+ $field-group-code-border-radius: $control-code-border-radius !default;
20
20
  $field-group-code-border-color: var(--#{$prefix}primary-a5) !default;
21
21
  $field-group-code-background-color: var(--#{$prefix}background-color) !default;
22
22
  $field-group-code-color: var(--#{$prefix}primary-11) !default;
@@ -70,7 +70,7 @@ $select-option-text-transform: null !default;
70
70
  $select-option-indicator-font-size: var(--#{$prefix}font-size-sm) !default;
71
71
 
72
72
  // Popover
73
- $select-popover-min-width: 142px !default;
73
+ $select-popover-min-width: 150px !default;
74
74
 
75
75
  // Variants
76
76
  $select-variants: $control-variants !default;
@@ -141,7 +141,7 @@
141
141
 
142
142
  // Popover
143
143
  &__popover {
144
- width: min-content;
144
+ width: fit-content;
145
145
  min-width: max(
146
146
  $select-popover-min-width,
147
147
  calc(var(--radix-popover-trigger-width) - $control-border-width * 2)
@@ -42,14 +42,14 @@
42
42
  &__arrow {
43
43
  fill: $popover-arrow-color;
44
44
  filter: if(
45
- $popover-arrow-border-width > 0,
46
- drop-shadow(0 $popover-arrow-border-width 0 $popover-arrow-border-color),
47
- null
45
+ sass($popover-arrow-border-width > 0): drop-shadow(
46
+ 0 $popover-arrow-border-width 0 $popover-arrow-border-color
47
+ )
48
48
  );
49
49
  margin-top: if(
50
- $popover-arrow-border-width > 0,
51
- calc($popover-arrow-border-width * -1),
52
- null
50
+ sass($popover-arrow-border-width > 0): calc(
51
+ $popover-arrow-border-width * -1
52
+ )
53
53
  );
54
54
 
55
55
  // XXX: Firefox doesn't seem to properly rotate the shadow at 180º
@@ -57,12 +57,10 @@
57
57
  @-moz-document url-prefix() {
58
58
  #{$popover}[data-side="bottom"] & {
59
59
  filter: if(
60
- $popover-arrow-border-width > 0,
61
- drop-shadow(
62
- 0 calc($popover-arrow-border-width * -1) 0
63
- $popover-arrow-border-color
64
- ),
65
- null
60
+ sass($popover-arrow-border-width > 0): drop-shadow(
61
+ 0 calc($popover-arrow-border-width * -1) 0
62
+ $popover-arrow-border-color
63
+ )
66
64
  );
67
65
  }
68
66
  }
@@ -8,23 +8,22 @@
8
8
  // Minimum breakpoint width.
9
9
  @function breakpoint-min($size, $breakpoint-by-size: $breakpoint-by-size) {
10
10
  $min: map.get($breakpoint-by-size, $size);
11
- @return if($min != 0, $min, null);
11
+ @return if(sass($min != 0): $min);
12
12
  }
13
13
 
14
14
  // Maximum breakpoint width (-0.02 to work around limitations of `-min`/`-max`
15
15
  // prefixes and 0.02 instead of 0.01 to work around a Safari rounding bug).
16
16
  @function breakpoint-max($size, $breakpoint-by-size: $breakpoint-by-size) {
17
17
  $max: map.get($breakpoint-by-size, $size);
18
- @return if($max and $max > 0, $max - 0.02, null);
18
+ @return if(sass($max and $max > 0): $max - 0.02);
19
19
  }
20
20
 
21
21
  // Returns a blank string if smallest breakpoint, otherwise returns the name
22
22
  // with a dash in front.
23
23
  @function breakpoint-infix($size, $breakpoint-by-size: $breakpoint-by-size) {
24
24
  @return if(
25
- breakpoint-min($size, $breakpoint-by-size) == null,
26
- "",
27
- "-#{$size}"
25
+ sass(breakpoint-min($size, $breakpoint-by-size) == null): "" ;
26
+ else: "-#{$size}"
28
27
  );
29
28
  }
30
29
 
@@ -1,15 +1,19 @@
1
1
  @function css-transparentize($color, $opacity) {
2
2
  @return if(
3
- $color == null or $opacity == null,
4
- null,
5
- color-mix(in srgb, $color calc($opacity * 100%), transparent)
3
+ sass($color != null and $opacity != null): color-mix(
4
+ in srgb,
5
+ $color calc($opacity * 100%),
6
+ transparent
7
+ )
6
8
  );
7
9
  }
8
10
 
9
11
  @function css-lighten($color, $percentage) {
10
12
  @return if(
11
- $color == null or $percentage == null,
12
- null,
13
- color-mix(in srgb, $color calc(100% - $percentage), #fff)
13
+ sass($color != null and $percentage != null): color-mix(
14
+ in srgb,
15
+ $color calc(100% - $percentage),
16
+ #fff
17
+ )
14
18
  );
15
19
  }
@@ -3,6 +3,6 @@
3
3
  // Declares a CSS variable when the values isn't `null`.
4
4
  @mixin declare-var($var, $value: null) {
5
5
  @if ($value != null and $value != NULL) {
6
- #{$var}: #{if($value == "", "", meta.inspect($value))};
6
+ #{$var}: #{if(sass($value == ""): "" ; else: meta.inspect($value))};
7
7
  }
8
8
  }
@@ -1,5 +1,5 @@
1
1
  // Returns the value with `!important` appended if it isn't `null`, or `null`
2
2
  // otherwise
3
3
  @function maybe-important($v) {
4
- @return if($v == null, null, #{$v} !important);
4
+ @return if(sass($v != null): #{$v} !important);
5
5
  }