@ostack.tech/ui 1.2.0 → 1.3.0-beta.1

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 (139) hide show
  1. package/dist/chunks/{en-DGLb7rrz.js → en-W4OWqPrv.js} +3 -4
  2. package/dist/chunks/en-W4OWqPrv.js.map +1 -0
  3. package/dist/chunks/{platformUtils-dLFQaWJG.js → platformUtils-Dm2Fkhni.js} +2 -3
  4. package/dist/chunks/{platformUtils-dLFQaWJG.js.map → platformUtils-Dm2Fkhni.js.map} +1 -1
  5. package/dist/locales/en-GB.js +2 -3
  6. package/dist/locales/en-GB.js.map +1 -1
  7. package/dist/locales/en-US.js +2 -3
  8. package/dist/locales/en-US.js.map +1 -1
  9. package/dist/locales/fr-FR.js +2 -3
  10. package/dist/locales/fr-FR.js.map +1 -1
  11. package/dist/locales/pt-PT.js +2 -3
  12. package/dist/locales/pt-PT.js.map +1 -1
  13. package/dist/ostack-ui.css +942 -255
  14. package/dist/ostack-ui.js +9889 -7842
  15. package/dist/ostack-ui.js.map +1 -1
  16. package/package.json +6 -6
  17. package/scss/_utils.scss +2 -1
  18. package/scss/components/ButtonGroup/_ButtonGroup.scss +7 -4
  19. package/scss/components/Calendar/_Calendar.scss +0 -1
  20. package/scss/components/Card/_Card.scss +16 -7
  21. package/scss/components/Code/_Code.scss +3 -3
  22. package/scss/components/Container/_Container.scss +3 -3
  23. package/scss/components/ControlCode/_ControlCode.scss +1 -1
  24. package/scss/components/DataTable/_DataTable.scss +8 -8
  25. package/scss/components/DescriptionList/_DescriptionList.scss +1 -1
  26. package/scss/components/DropdownMenu/_DropdownMenu.scss +8 -2
  27. package/scss/components/Feedback/_Feedback.scss +12 -9
  28. package/scss/components/Field/_Field.scss +3 -3
  29. package/scss/components/FieldGroup/_FieldGroup.scss +2 -1
  30. package/scss/components/Form/_Form.scss +2 -2
  31. package/scss/components/Grid/_Grid.scss +17 -11
  32. package/scss/components/Heading/_Heading-variables.scss +4 -1
  33. package/scss/components/Heading/_Heading.scss +22 -10
  34. package/scss/components/HelperText/_HelperText.scss +9 -7
  35. package/scss/components/Icon/_Icon-variables.scss +1 -0
  36. package/scss/components/Icon/_Icon.scss +2 -6
  37. package/scss/components/Keyboard/_Keyboard-variables.scss +4 -2
  38. package/scss/components/Keyboard/_Keyboard.scss +8 -4
  39. package/scss/components/Label/_Label-variables.scss +4 -0
  40. package/scss/components/Label/_Label.scss +13 -4
  41. package/scss/components/Link/_Link-variables.scss +1 -1
  42. package/scss/components/Link/_Link.scss +12 -3
  43. package/scss/components/Mark/_Mark.scss +2 -1
  44. package/scss/components/Spinner/_Spinner-variables.scss +1 -1
  45. package/scss/components/Spinner/_Spinner.scss +0 -7
  46. package/scss/components/Stack/_Stack.scss +22 -12
  47. package/scss/components/Stepper/_Stepper-variables.scss +0 -4
  48. package/scss/components/Stepper/_Stepper.scss +1 -6
  49. package/scss/components/Tabs/_Tabs-variables.scss +0 -1
  50. package/scss/components/Tabs/_Tabs.scss +4 -3
  51. package/scss/components/Tag/_Tag-variables.scss +1 -0
  52. package/scss/components/Tag/_Tag.scss +4 -3
  53. package/scss/components/Text/_Text-variables.scss +4 -0
  54. package/scss/components/Text/_Text.scss +19 -0
  55. package/scss/index.scss +5 -0
  56. package/scss/scss/helpers/_margin-utils.scss +35 -0
  57. package/scss/scss/helpers/_padding-utils.scss +35 -0
  58. package/scss/scss/helpers/_print-utils.scss +1 -1
  59. package/scss/scss/helpers/_sizing-utils.scss +45 -0
  60. package/scss/scss/helpers/_text-utils.scss +43 -0
  61. package/scss/scss/placeholders/checkable-group/_checkable-group.scss +2 -2
  62. package/scss/scss/placeholders/control/_control.scss +1 -9
  63. package/scss/scss/placeholders/menu/_menu.scss +2 -1
  64. package/scss/scss/placeholders/popover/_popover.scss +2 -2
  65. package/scss/scss/utils/_responsive-values.scss +7 -8
  66. package/types/components/Actions/Action.d.ts +1 -1
  67. package/types/components/Actions/Actions.d.ts +1 -1
  68. package/types/components/Alert/Alert.d.ts +3 -2
  69. package/types/components/Box/Box.d.ts +37 -0
  70. package/types/components/Box/index.d.ts +1 -0
  71. package/types/components/Button/Button.d.ts +3 -2
  72. package/types/components/ButtonGroup/ButtonGroup.d.ts +3 -2
  73. package/types/components/Calendar/Calendar.d.ts +3 -2
  74. package/types/components/Calendar/CalendarContext.d.ts +1 -0
  75. package/types/components/Card/Card.d.ts +3 -2
  76. package/types/components/Card/CardTitle.d.ts +3 -2
  77. package/types/components/Checkbox/Checkbox.d.ts +2 -1
  78. package/types/components/CheckboxGroup/CheckboxGroup.d.ts +3 -2
  79. package/types/components/Code/Code.d.ts +4 -2
  80. package/types/components/Container/Container.d.ts +3 -2
  81. package/types/components/Control/Control.d.ts +13 -13
  82. package/types/components/ControlCode/ControlCode.d.ts +3 -2
  83. package/types/components/DataTable/DataTableBody.d.ts +2 -3
  84. package/types/components/DataTable/DataTablePagination.d.ts +3 -2
  85. package/types/components/DataTable/DataTableRowsPerPage.d.ts +3 -2
  86. package/types/components/DataTable/ScrolledDataTableRows.d.ts +2 -2
  87. package/types/components/DataTable/useVirtualizerSnapshot.d.ts +13 -0
  88. package/types/components/DateRangeInput/DateRangeInput.d.ts +5 -6
  89. package/types/components/DropdownMenu/DropdownMenuContent.d.ts +3 -2
  90. package/types/components/Feedback/Feedback.d.ts +6 -4
  91. package/types/components/Feedback/FeedbackList.d.ts +3 -2
  92. package/types/components/Field/Field.d.ts +5 -10
  93. package/types/components/FieldGroup/FieldGroup.d.ts +3 -2
  94. package/types/components/FieldGroup/FieldGroupTitle.d.ts +3 -2
  95. package/types/components/Form/Form.d.ts +3 -8
  96. package/types/components/Grid/Grid.d.ts +11 -4
  97. package/types/components/Grid/GridContext.d.ts +1 -1
  98. package/types/components/Heading/Heading.d.ts +12 -3
  99. package/types/components/HelperText/HelperText.d.ts +4 -2
  100. package/types/components/Icon/Icon.d.ts +9 -4
  101. package/types/components/IconButton/IconButton.d.ts +3 -2
  102. package/types/components/Keybinds/Keybinds.d.ts +3 -2
  103. package/types/components/Keyboard/Keyboard.d.ts +17 -4
  104. package/types/components/Label/Label.d.ts +11 -2
  105. package/types/components/Link/Link.d.ts +4 -2
  106. package/types/components/Mark/Mark.d.ts +7 -5
  107. package/types/components/MenuList/MenuList.d.ts +3 -2
  108. package/types/components/Popover/Popover.d.ts +1 -1
  109. package/types/components/Popover/PopoverContent.d.ts +4 -2
  110. package/types/components/Printer/PrinterContent.d.ts +3 -9
  111. package/types/components/RadioGroup/Radio.d.ts +2 -1
  112. package/types/components/RadioGroup/RadioGroup.d.ts +3 -2
  113. package/types/components/Root/Root.d.ts +3 -8
  114. package/types/components/Root/RootElement.d.ts +2 -2
  115. package/types/components/Separator/Separator.d.ts +2 -1
  116. package/types/components/Slot/Slot.d.ts +1 -1
  117. package/types/components/Spinner/Spinner.d.ts +7 -4
  118. package/types/components/Stack/Stack.d.ts +10 -11
  119. package/types/components/Stack/StackContext.d.ts +1 -1
  120. package/types/components/Stepper/StepContent.d.ts +3 -8
  121. package/types/components/Stepper/StepList.d.ts +3 -2
  122. package/types/components/Stepper/Stepper.d.ts +9 -13
  123. package/types/components/Table/Table.d.ts +2 -1
  124. package/types/components/Tabs/TabContent.d.ts +3 -2
  125. package/types/components/Tabs/TabList.d.ts +2 -1
  126. package/types/components/Tabs/Tabs.d.ts +6 -4
  127. package/types/components/Tag/Tag.d.ts +4 -2
  128. package/types/components/Text/Text.d.ts +48 -0
  129. package/types/components/Text/index.d.ts +1 -0
  130. package/types/index.d.ts +10 -3
  131. package/types/utils/localeUtils.d.ts +8 -0
  132. package/types/utils/responsiveValues.d.ts +41 -0
  133. package/types/utils/useMarginProps.d.ts +46 -0
  134. package/types/utils/usePaddingProps.d.ts +46 -0
  135. package/types/utils/useSizingProps.d.ts +23 -0
  136. package/types/utils/useTextProps.d.ts +50 -0
  137. package/dist/chunks/en-DGLb7rrz.js.map +0 -1
  138. package/types/utils/changeCase.d.ts +0 -2
  139. package/types/utils/useResponsiveValues.d.ts +0 -41
@@ -1,9 +1,10 @@
1
1
  import { Tabs as TabsPrimitive } from "radix-ui";
2
2
  import type { ComponentProps } from "react";
3
+ import { type BoxProps } from "../Box";
3
4
  /** Tabs variants. */
4
5
  export type TabsVariant = "default" | "annexes";
5
6
  /** Properties of the tabs component. */
6
- export interface TabsProps extends Omit<ComponentProps<typeof TabsPrimitive.Root>, "defaultValue" | "value" | "orientation" | "dir"> {
7
+ export interface TabsProps extends Omit<BoxProps, "as">, Omit<ComponentProps<typeof TabsPrimitive.Root>, "defaultValue" | "value" | "orientation" | "dir"> {
7
8
  /**
8
9
  * Tabs variant.
9
10
  *
@@ -22,7 +23,8 @@ export interface TabsProps extends Omit<ComponentProps<typeof TabsPrimitive.Root
22
23
  *
23
24
  * The `value` set on each tab should match the `value` of its content.
24
25
  *
25
- * Built on top of the [Radix Tabs primitive](https://radix-ui.com/primitives/docs/components/tabs).
26
+ * Built on top of the [Radix Tabs primitive](https://radix-ui.com/primitives/docs/components/tabs)
27
+ * and the [`Box` component](/docs/ostack-ui-layout-box--docs).
26
28
  *
27
29
  * It composes the following subcomponents:
28
30
  *
@@ -38,7 +40,7 @@ export interface TabsProps extends Omit<ComponentProps<typeof TabsPrimitive.Root
38
40
  * function Bills() {
39
41
  * return (
40
42
  * <Tabs>
41
- * <TabList>
43
+ * <TabList mb={2}>
42
44
  * <Tab value="water">Water</Tab>
43
45
  * <Tab value="electricity">Electricity</Tab>
44
46
  * <Tab value="gas">Gas</Tab>
@@ -51,4 +53,4 @@ export interface TabsProps extends Omit<ComponentProps<typeof TabsPrimitive.Root
51
53
  * }
52
54
  * ```
53
55
  */
54
- export declare function Tabs({ variant, defaultValue, value, onValueChange, showAllTabsWhilePrinting, className, ...otherProps }: TabsProps): import("react").JSX.Element;
56
+ export declare function Tabs({ variant, defaultValue, value, onValueChange, activationMode, showAllTabsWhilePrinting, className, ...otherProps }: TabsProps): import("react").JSX.Element;
@@ -1,5 +1,7 @@
1
1
  import type { ComponentProps } from "react";
2
2
  import type { AccentColor } from "../../utils/accent.ts";
3
+ import { type UseMarginPropsOptions } from "../../utils/useMarginProps.ts";
4
+ import { type UseTextPropsOptions } from "../../utils/useTextProps.ts";
3
5
  import { type CloseButtonProps } from "../CloseButton";
4
6
  import { type CollapsibleContentProps } from "../Collapsible";
5
7
  import { type IconProp, type IconProps } from "../Icon";
@@ -10,7 +12,7 @@ export type TagColor = AccentColor;
10
12
  /** Tag's icon placement. */
11
13
  export type TagIconPlacement = "start" | "end";
12
14
  /** Properties of the tag component. */
13
- export interface TagProps extends ComponentProps<"span"> {
15
+ export interface TagProps extends UseMarginPropsOptions, UseTextPropsOptions, ComponentProps<"span"> {
14
16
  /**
15
17
  * Change the component to the HTML tag or custom component of the only child. This will merge the
16
18
  * original component props with the props of the supplied element/component and change the
@@ -89,4 +91,4 @@ export interface TagProps extends ComponentProps<"span"> {
89
91
  * }
90
92
  * ```
91
93
  */
92
- export declare function Tag({ asChild, variant, color, defaultOpen, open, onOpenChange, icon, iconPlacement, pill, showCloseButton, className, containerProps, contentProps, iconProps, closeButtonProps, children, ...otherProps }: TagProps): import("react").JSX.Element;
94
+ export declare function Tag({ asChild, variant, color, defaultOpen, open, onOpenChange, icon, iconPlacement, pill, showCloseButton, className, truncate, style, containerProps, contentProps, iconProps, closeButtonProps, children, ...otherProps }: TagProps): import("react").JSX.Element;
@@ -0,0 +1,48 @@
1
+ import type { AccentColor } from "../../utils/accent.ts";
2
+ import type { PolymorphicProps } from "../../utils/polymorphicTypes.ts";
3
+ import { type UseMarginPropsOptions } from "../../utils/useMarginProps.ts";
4
+ import { type UseTextPropsOptions } from "../../utils/useTextProps.ts";
5
+ /** Elements text can be rendered as. */
6
+ export type TextAs = "span" | "div" | "p" | "strong" | "em" | "s" | "sub" | "sup" | "time" | "figcaption";
7
+ /** Text colours. */
8
+ export type TextColor = AccentColor;
9
+ /** Properties of the text component. */
10
+ export type TextProps<TAs extends TextAs = "span"> = PolymorphicProps<TextAs, TAs, "span", TextOwnProps>;
11
+ /** Own properties of the text component. */
12
+ export interface TextOwnProps extends UseMarginPropsOptions, UseTextPropsOptions {
13
+ /**
14
+ * Change the component to the HTML tag or custom component of the only child. This will merge the
15
+ * original component props with the props of the supplied element/component and change the
16
+ * underlying DOM node.
17
+ */
18
+ asChild?: boolean;
19
+ /**
20
+ * Colour of the text.
21
+ *
22
+ * @default "primary"
23
+ */
24
+ color?: TextColor;
25
+ /** Uses a higher contrast colour for the text. */
26
+ highContrast?: boolean;
27
+ }
28
+ /**
29
+ * Component used to render text. By default, it renders as a [`<span>`
30
+ * element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a). Use the `as`
31
+ * property to render as an `<em>`, `<p>`, `<strong>`, or other text elements.
32
+ *
33
+ * Example usage:
34
+ *
35
+ * ```tsx
36
+ * import { Text } from "@ostack.tech/ui";
37
+ *
38
+ * function LoremIpsum() {
39
+ * return (
40
+ * <Text>
41
+ * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
42
+ * incididunt ut labore et dolore magna aliqua.
43
+ * </Text>
44
+ * );
45
+ * }
46
+ * ```
47
+ */
48
+ export declare function Text<TAs extends TextAs = "span">({ as, asChild, color, highContrast, className, style, ...otherProps }: TextProps<TAs>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Text.tsx";
package/types/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./components/Root";
2
2
  export * from "./components/Actions";
3
3
  export * from "./components/Alert";
4
4
  export * from "./components/AlertDialog";
5
+ export * from "./components/Box";
5
6
  export * from "./components/Button";
6
7
  export * from "./components/ButtonGroup";
7
8
  export * from "./components/Calendar";
@@ -56,6 +57,7 @@ export * from "./components/Stepper";
56
57
  export * from "./components/Table";
57
58
  export * from "./components/Tabs";
58
59
  export * from "./components/Tag";
60
+ export * from "./components/Text";
59
61
  export * from "./components/TextArea";
60
62
  export * from "./components/Toast";
61
63
  export * from "./components/Tooltip";
@@ -69,10 +71,10 @@ export * from "./providers/ToastManagerProvider";
69
71
  export * from "./utils/boolDataAttr.ts";
70
72
  export * from "./utils/breakpoints.ts";
71
73
  export * from "./utils/combineAriaIds.ts";
72
- export * from "./utils/useCombinedEventHandler.ts";
73
74
  export * from "./utils/cx.ts";
74
75
  export * from "./utils/filtering.ts";
75
76
  export * from "./utils/keyboardShortcut.ts";
77
+ export * from "./utils/localeUtils.ts";
76
78
  export * from "./utils/nativeControls.ts";
77
79
  export * from "./utils/navigate.ts";
78
80
  export * from "./utils/numericStringUtils.ts";
@@ -80,9 +82,11 @@ export * from "./utils/parseChildren.ts";
80
82
  export * from "./utils/parseDateStrict.ts";
81
83
  export * from "./utils/polymorphicTypes.ts";
82
84
  export * from "./utils/reactCompilerUtils.ts";
85
+ export * from "./utils/responsiveValues.ts";
83
86
  export * from "./utils/setNativeProperty.ts";
84
87
  export * from "./utils/sorting.ts";
85
88
  export * from "./utils/stringHash.ts";
89
+ export * from "./utils/useCombinedEventHandler.ts";
86
90
  export * from "./utils/useCombinedRef.ts";
87
91
  export * from "./utils/useConstant.ts";
88
92
  export * from "./utils/useControllableState.ts";
@@ -91,16 +95,19 @@ export * from "./utils/useDateTransformer.tsx";
91
95
  export * from "./utils/useIntersectionObserver.ts";
92
96
  export * from "./utils/useLatestRef.ts";
93
97
  export * from "./utils/useLocation.ts";
98
+ export * from "./utils/useMarginProps.ts";
94
99
  export * from "./utils/useMeasure.ts";
95
100
  export * from "./utils/useMediaQuery.ts";
96
101
  export * from "./utils/useNumericTransformer.tsx";
102
+ export * from "./utils/usePaddingProps.ts";
97
103
  export * from "./utils/usePrevious.ts";
98
- export * from "./utils/useResponsiveValues.ts";
99
104
  export * from "./utils/useSafeLayoutEffect.ts";
100
- export * from "./utils/useScrollbarSize.ts";
101
105
  export * from "./utils/useScrollPosition.ts";
106
+ export * from "./utils/useScrollbarSize.ts";
102
107
  export * from "./utils/useSearchParam.ts";
103
108
  export * from "./utils/useSearchParams.ts";
109
+ export * from "./utils/useSizingProps.ts";
104
110
  export * from "./utils/useSpacing.ts";
111
+ export * from "./utils/useTextProps.ts";
105
112
  export * from "./utils/warnOnce.ts";
106
113
  export * from "./utils/zustandUtils.ts";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns the label for a given locale.
3
+ *
4
+ * If the list of available locales is provided as the second argument and there are multiple
5
+ * available locales sharing the provided locale's language, then the label will contain the
6
+ * provided locale's region for disambiguation.
7
+ */
8
+ export declare function localeLabel<T extends string = string>(locale: T, availableLocales?: readonly T[]): string;
@@ -0,0 +1,41 @@
1
+ import { type Breakpoint } from "./breakpoints.ts";
2
+ import { type UseCssVarsOptions } from "./useCssVars.ts";
3
+ /** Value allowing for different values depending on the current breakpoint. */
4
+ export type Responsive<T = unknown> = T | ResponsiveObject<T>;
5
+ /** Value containing different values depending on the current breakpoint. */
6
+ export type ResponsiveObject<T = unknown> = Partial<Record<Breakpoint, T>>;
7
+ /** Options available to the {@link useResponsiveValue} hook. */
8
+ export type UseResponsiveValueOptions = UseCssVarsOptions;
9
+ /** Options available to the {@link useResponsiveValues} hook. */
10
+ export type UseResponsiveValuesOptions = UseResponsiveValueOptions;
11
+ /** Properties supporting responsive values. */
12
+ export interface ResponsiveValueProps {
13
+ cssVars: Record<string, string>;
14
+ dataAttrs: Record<string, string>;
15
+ }
16
+ /**
17
+ * Returns an object of CSS variables for multiple responsive values, together with data attributes
18
+ * specifying which breakpoints of each value have an associated CSS variable.
19
+ */
20
+ export declare function useResponsiveValue<T>(baseName: string, propName: string, value?: Responsive<T>, mapper?: (value: T) => unknown, options?: UseResponsiveValueOptions): ResponsiveValueProps;
21
+ /**
22
+ * Returns an object of CSS variables for a responsive value, together with data attributes
23
+ * specifying which breakpoints have an associated CSS variable.
24
+ */
25
+ export declare function useResponsiveValues<T extends Record<string, unknown>, TMappers extends {
26
+ [TKey in keyof T]: (value: T[TKey] extends Responsive<infer TValue> | undefined ? TValue : never) => unknown;
27
+ }>(baseName: string, values: T, mappers?: Partial<TMappers>, options?: UseResponsiveValuesOptions): ResponsiveValueProps;
28
+ /**
29
+ * Resolves a `Responsive<T>` value to the specific value matching the current breakpoint.
30
+ *
31
+ * @param value Responsive value.
32
+ * @param defaultValue Fallback value if no matching breakpoint is found or if `value` is
33
+ * `undefined`.
34
+ * @returns The resolved value for the current breakpoint, or `defaultValue`.
35
+ */
36
+ export declare function useCurrentResponsiveValue<T = unknown>(value: Responsive<T> | undefined): T | undefined;
37
+ export declare function useCurrentResponsiveValue<T = unknown>(value: Responsive<T> | undefined, defaultValue: T): T;
38
+ /** Merges two responsive values together. */
39
+ export declare function mergeResponsiveValues<T = unknown>(value: Responsive<T> | undefined, override: Responsive<T> | undefined): Responsive<T> | undefined;
40
+ /** Whether the provided value is (probably) a responsive value object. */
41
+ export declare function isResponsiveValueObject<T = unknown>(value: Responsive<T>): value is ResponsiveObject<T>;
@@ -0,0 +1,46 @@
1
+ import type { CSSProperties } from "react";
2
+ import { type Responsive, type ResponsiveValueProps } from "./responsiveValues.ts";
3
+ /** Properties available to the {@link useMarginProps} hook. */
4
+ export interface UseMarginPropsOptions {
5
+ /**
6
+ * Margin area on all four sides of an element. When a number is provided, each unit corresponds
7
+ * to `var(--o-ui-space)`.
8
+ */
9
+ m?: Responsive<number | CSSProperties["marginTop"]>;
10
+ /**
11
+ * Margin area on the top and bottom sides of an element. When a number is provided, each unit
12
+ * corresponds to `var(--o-ui-space)`.
13
+ */
14
+ my?: Responsive<number | CSSProperties["marginTop"]>;
15
+ /**
16
+ * Margin area on the left and right sides of an element. When a number is provided, each unit
17
+ * corresponds to `var(--o-ui-space)`.
18
+ */
19
+ mx?: Responsive<number | CSSProperties["marginLeft"]>;
20
+ /**
21
+ * Margin area on the top side of an element. When a number is provided, each unit corresponds to
22
+ * `var(--o-ui-space)`.
23
+ */
24
+ mt?: Responsive<number | CSSProperties["marginTop"]>;
25
+ /**
26
+ * Margin area on the right side of an element. When a number is provided, each unit corresponds
27
+ * to `var(--o-ui-space)`.
28
+ */
29
+ mr?: Responsive<number | CSSProperties["marginRight"]>;
30
+ /**
31
+ * Margin area on the bottom side of an element. When a number is provided, each unit corresponds
32
+ * to `var(--o-ui-space)`.
33
+ */
34
+ mb?: Responsive<number | CSSProperties["marginBottom"]>;
35
+ /**
36
+ * Margin area on the left side of an element. When a number is provided, each unit corresponds to
37
+ * `var(--o-ui-space)`.
38
+ */
39
+ ml?: Responsive<number | CSSProperties["marginLeft"]>;
40
+ }
41
+ /** Result of the {@link useMarginProps} hook. */
42
+ export type UseMarginPropsResult<T extends UseMarginPropsOptions> = Omit<T, keyof UseMarginPropsOptions> & {
43
+ marginProps: ResponsiveValueProps;
44
+ };
45
+ /** Hook providing access to all margin properties. */
46
+ export declare function useMarginProps<T extends UseMarginPropsOptions>({ m, my, mx, mt: mtProp, mr: mrProp, mb: mbProp, ml: mlProp, ...otherProps }: T): UseMarginPropsResult<T>;
@@ -0,0 +1,46 @@
1
+ import type { CSSProperties } from "react";
2
+ import { type Responsive, type ResponsiveValueProps } from "./responsiveValues.ts";
3
+ /** Options available to the {@link usePaddingProps} hook. */
4
+ export interface UsePaddingPropsOptions {
5
+ /**
6
+ * Padding area on all four sides of an element. When a number is provided, each unit corresponds
7
+ * to `var(--o-ui-space)`.
8
+ */
9
+ p?: Responsive<number | CSSProperties["paddingTop"]>;
10
+ /**
11
+ * Padding area on the top and bottom sides of an element. When a number is provided, each unit
12
+ * corresponds to `var(--o-ui-space)`.
13
+ */
14
+ py?: Responsive<number | CSSProperties["paddingTop"]>;
15
+ /**
16
+ * Padding area on the left and right sides of an element. When a number is provided, each unit
17
+ * corresponds to `var(--o-ui-space)`.
18
+ */
19
+ px?: Responsive<number | CSSProperties["paddingLeft"]>;
20
+ /**
21
+ * Padding area on the top side of an element. When a number is provided, each unit corresponds to
22
+ * `var(--o-ui-space)`.
23
+ */
24
+ pt?: Responsive<number | CSSProperties["paddingTop"]>;
25
+ /**
26
+ * Padding area on the right side of an element. When a number is provided, each unit corresponds
27
+ * to `var(--o-ui-space)`.
28
+ */
29
+ pr?: Responsive<number | CSSProperties["paddingRight"]>;
30
+ /**
31
+ * Padding area on the bottom side of an element. When a number is provided, each unit corresponds
32
+ * to `var(--o-ui-space)`.
33
+ */
34
+ pb?: Responsive<number | CSSProperties["paddingBottom"]>;
35
+ /**
36
+ * Padding area on the left side of an element. When a number is provided, each unit corresponds
37
+ * to `var(--o-ui-space)`.
38
+ */
39
+ pl?: Responsive<number | CSSProperties["paddingLeft"]>;
40
+ }
41
+ /** Result of the {@link usePaddingProps} hook. */
42
+ export type UsePaddingPropsResult<T extends UsePaddingPropsOptions> = Omit<T, keyof UsePaddingPropsOptions> & {
43
+ paddingProps: ResponsiveValueProps;
44
+ };
45
+ /** Hook providing access to all padding properties. */
46
+ export declare function usePaddingProps<T extends UsePaddingPropsOptions>({ p, py, px, pt: ptProp, pr: prProp, pb: pbProp, pl: plProp, ...otherProps }: T): UsePaddingPropsResult<T>;
@@ -0,0 +1,23 @@
1
+ import type { CSSProperties } from "react";
2
+ import { type Responsive, type ResponsiveValueProps } from "./responsiveValues.ts";
3
+ /** Options available to the {@link useSizingProps} hook. */
4
+ export interface UseSizingPropsOptions {
5
+ /** Width of an element. When a number is provided, it represents a size in pixels. */
6
+ width?: Responsive<CSSProperties["width"]>;
7
+ /** Minimum width of an element. When a number is provided, it represents a size in pixels. */
8
+ minWidth?: Responsive<CSSProperties["minWidth"]>;
9
+ /** Maximum width of an element. When a number is provided, it represents a size in pixels. */
10
+ maxWidth?: Responsive<CSSProperties["maxWidth"]>;
11
+ /** Height of an element. When a number is provided, it represents a size in pixels. */
12
+ height?: Responsive<CSSProperties["height"]>;
13
+ /** Minimum height of an element. When a number is provided, it represents a size in pixels. */
14
+ minHeight?: Responsive<CSSProperties["minHeight"]>;
15
+ /** Maximum height of an element. When a number is provided, it represents a size in pixels. */
16
+ maxHeight?: Responsive<CSSProperties["maxHeight"]>;
17
+ }
18
+ /** Result of the {@link useSizingProps} hook. */
19
+ export type UseSizingPropsResult<T extends UseSizingPropsOptions> = Omit<T, keyof UseSizingPropsOptions> & {
20
+ sizingProps: ResponsiveValueProps;
21
+ };
22
+ /** Hook providing access to all sizing properties. */
23
+ export declare function useSizingProps<T extends UseSizingPropsOptions>({ width, minWidth, maxWidth, height, minHeight, maxHeight, ...otherProps }: T): UseSizingPropsResult<T>;
@@ -0,0 +1,50 @@
1
+ import type { CSSProperties } from "react";
2
+ import { type Responsive, type ResponsiveValueProps } from "./responsiveValues.ts";
3
+ /** Available font weights, matching SCSS variables. */
4
+ declare const FONT_WEIGHTS: {
5
+ thin: number;
6
+ "extra-light": number;
7
+ light: number;
8
+ normal: number;
9
+ medium: number;
10
+ semibold: number;
11
+ bold: number;
12
+ "extra-bold": number;
13
+ black: number;
14
+ };
15
+ /** Size of the text. */
16
+ export type TextSize = "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl";
17
+ /** Weight of the text. */
18
+ export type TextWeight = keyof typeof FONT_WEIGHTS;
19
+ /** Properties available to the {@link useTextProps} hook. */
20
+ export interface UseTextPropsOptions {
21
+ /** Size of the text. */
22
+ size?: Responsive<TextSize>;
23
+ /**
24
+ * Truncates text with an ellipsis. For pitfalls, see: [Flexbox and Truncated
25
+ * Text](https://css-tricks.com/flexbox-truncated-text/).
26
+ */
27
+ truncate?: boolean;
28
+ /** Sets the `text-align` CSS property. */
29
+ align?: Responsive<CSSProperties["textAlign"]>;
30
+ /**
31
+ * Sets the `font-weight` CSS property.
32
+ *
33
+ * Besides standard CSS values, the following aliases are available: `"thin"` (100),
34
+ * `"extra-light"` (200), `"light"` (300), `"normal"` (400), `"medium"` (500), `"semibold"` (600),
35
+ * `"bold"` (700), `"extra-bold"` (800), and `"black"` (900).
36
+ */
37
+ weight?: Responsive<TextWeight | CSSProperties["fontWeight"]>;
38
+ /**
39
+ * Set the `text-wrap` CSS property. A `true`/`false` boolean value sets the property to
40
+ * `"wrap"`/`"nowrap"` respectively.
41
+ */
42
+ wrap?: Responsive<boolean | CSSProperties["textWrap"]>;
43
+ }
44
+ /** Result of the {@link useTextProps} hook. */
45
+ export type UseTextPropsResult<T extends UseTextPropsOptions> = Omit<T, keyof UseTextPropsOptions> & {
46
+ textProps: ResponsiveValueProps;
47
+ };
48
+ /** Hook providing access to all text properties. */
49
+ export declare function useTextProps<T extends UseTextPropsOptions>({ size, truncate, align, weight, wrap, ...otherProps }: T): UseTextPropsResult<T>;
50
+ export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"en-DGLb7rrz.js","names":[],"sources":["../../src/locales/en.tsx"],"sourcesContent":["import type { LocalizationObject } from \"../providers/LocalizationProvider\";\nimport { IS_APPLE } from \"../utils/platformUtils.ts\";\n\n/** `en` locale (partial). */\nexport const en: Omit<LocalizationObject, \"languageTag\" | \"dayPickerLocale\"> = {\n ActionSplit: {\n splitLabel: \"More options\",\n },\n ActionsSecondary: {\n label: \"More actions\",\n },\n AlertDialog: {\n okText: \"OK\",\n },\n Calendar: {\n monthSelectLabel: \"Month\",\n yearSelectLabel: \"Year\",\n previousMonthLabel: \"Previous month\",\n nextMonthLabel: \"Next month\",\n },\n CloseButton: {\n label: \"Close\",\n },\n CollapsibleTrigger: {\n expandLabel: \"Show\",\n collapseLabel: \"Hide\",\n },\n CommandMenu: {\n searchPlaceholder: \"Search…\",\n listLabel: \"Suggestions\",\n loadingLabel: \"Loading…\",\n emptyMessage: \"No results found.\",\n },\n CommandMenuDialog: {\n title: \"Command palette\",\n description: \"Search for a command…\",\n },\n ConfirmDialog: {\n cancelText: \"Cancel\",\n },\n ControlCode: {\n visuallyHiddenPrefix: \"Field\",\n },\n DataTable: {\n selectAllRowsLabel: \"Select all\",\n selectRowLabel: \"Select\",\n },\n DataTableContent: {\n emptyMessage: \"Nothing to show.\",\n },\n DataTableFilter: {\n \"aria-label\": \"Search table\",\n placeholder: \"Search…\",\n },\n DataTablePagination: {\n \"aria-label\": \"Table pagination\",\n rowsRangeSelectLabel: (total) => `Visible rows out of ${total}`,\n rowsRange: (range, total) => (\n <>\n Rows&nbsp;{range}&nbsp;of {total}\n </>\n ),\n previousPageButtonLabel: \"Previous page\",\n nextPageButtonLabel: \"Next page\",\n },\n DataTableRowsPerPage: {\n label: \"Rows per page:\",\n },\n DateInput: {\n selectedDateDescription: (date) => `Selected date, ${date}`,\n calendarButtonLabel: \"Open calendar\",\n },\n DateRangeInput: {\n startInputLabel: \"Start date\",\n endInputLabel: \"End date\",\n selectedDateRangeDescription: ({ start, end }) =>\n `Selected date range, ${start || \"missing start date\"} to ${end || \"missing end date\"}`,\n },\n ErrorBoundary: {\n fallbackMessage: (\n <>\n Something went wrong.\n <br />\n Press the button on the right to try again. If the problem persists, please try again later.\n </>\n ),\n resetButtonLabel: \"Retry\",\n },\n Feedback: {\n visuallyHiddenPrefix: (type) =>\n type === \"error\" ? \"Error,\" : type === \"warning\" ? \"Warning,\" : null,\n },\n FeedbackPopover: {\n label: \"Show feedback\",\n },\n FieldGroupHeader: {\n visuallyHiddenCodePrefix: \"Section\",\n },\n Form: {\n submitErrorMessage: \"An error occurred during submission. Please try again later.\",\n nativeErrorMessages: {\n valueMissing: \"Required.\",\n badInput: \"Unrecognized format.\",\n typeMismatch: (el) => {\n const type = (el as HTMLInputElement).type;\n return type === \"email\" ? \"Invalid email.\" : \"Invalid URL.\";\n },\n patternMismatch: \"Invalid format.\",\n tooShort: (el) => {\n const minLength = (el as HTMLInputElement).minLength;\n return `Requires at least ${minLength} ${minLength === 1 ? \"character\" : \"characters\"}.`;\n },\n tooLong: (el) => {\n const maxLength = (el as HTMLInputElement).maxLength;\n return `Limited to at most ${maxLength} ${maxLength === 1 ? \"character\" : \"characters\"}.`;\n },\n rangeUnderflow: (el) => {\n const min = (el as HTMLInputElement).min;\n return `Below minimum of ${min}.`;\n },\n rangeOverflow: (el) => {\n const max = (el as HTMLInputElement).max;\n return `Above maximum of ${max}.`;\n },\n stepMismatch: \"Invalid value increment.\",\n },\n },\n Input: {\n loadingDescription: \"Loading…\",\n clearButtonLabel: \"Clear\",\n },\n Keybinds: {\n keybindsSeparatorLabel: \"or\",\n keyPressesSeparatorLabel: \"then\",\n keyLabels: {\n Meta: IS_APPLE ? undefined : \"Windows Key\",\n },\n },\n Label: {\n helperButtonLabel: \"Show help\",\n },\n NumericInput: {\n decimalSeparator: \".\",\n groupingStyle: \"thousand\",\n groupSeparator: \",\",\n },\n RadioGroup: {\n clearDescription: \"Press Backspace or Delete to clear.\",\n },\n Select: {\n placeholder: \"Select…\",\n clearDescription: \"Press Backspace or Delete to clear.\",\n searchLabel: \"Search options\",\n optionsLabel: \"Options\",\n valueTagCloseButtonLabel: \"Remove\",\n },\n Step: {\n stepNumberLabel: (number) => `Step ${number}`,\n completedLabel: \"Completed\",\n },\n StepperFinishTrigger: {\n label: \"Finish\",\n },\n StepperNextTrigger: {\n label: \"Next\",\n },\n StepperPreviousTrigger: {\n label: \"Back\",\n },\n TableColumn: {\n helperButtonLabel: \"Show help\",\n },\n TableHead: {\n sortByColumnDescription: (sortDirection) =>\n sortDirection === null\n ? \"Clear sort\"\n : `Sort ${sortDirection === \"asc\" ? \"ascending\" : \"descending\"}`,\n },\n TabList: {\n scrollLeftButtonLabel: \"Scroll left\",\n scrollRightButtonLabel: \"Scroll right\",\n },\n ToastProvider: {\n label: \"Notification\",\n },\n ToastViewport: {\n label: \"Notifications ({hotkey})\",\n },\n};\n"],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- /** Converts camel case to kebab case. */
2
- export declare function camelToKebabCase(str: string): string;
@@ -1,41 +0,0 @@
1
- import { type Breakpoint } from "./breakpoints.ts";
2
- import { type UseCssVarsOptions } from "./useCssVars.ts";
3
- /** Value allowing for different values depending on the current breakpoint. */
4
- export type Responsive<T = unknown> = T | Partial<Record<Breakpoint, T>>;
5
- /** Options available to the {@link useResponsiveValues} hook. */
6
- export type UseResponsiveValuesOptions = UseCssVarsOptions;
7
- /** Result of the {@link useResponsiveValues} hook. */
8
- export interface UseResponsiveValuesResult {
9
- /**
10
- * Returns an object of CSS variables for multiple responsive values, together with data
11
- * attributes specifying which breakpoints of each value have an associated CSS variable.
12
- */
13
- responsiveValuesToCssVarsAndDataAttrs: <T extends Record<string, unknown>, TMappers extends {
14
- [TKey in keyof T]: (value: T[TKey] extends Responsive<infer TValue> | undefined ? TValue : never) => unknown;
15
- }>(componentName: string, values: T, mappers?: Partial<TMappers>) => {
16
- cssVars: Record<string, string | undefined>;
17
- dataAttrs: Record<string, string | undefined>;
18
- };
19
- /**
20
- * Returns an object of CSS variables for a responsive value, together with data attributes
21
- * specifying which breakpoints have an associated CSS variable.
22
- */
23
- responsiveValueToCssVarsAndDataAttrs: <T>(componentName: string, varName: string, value?: Responsive<T>, mapper?: (value: T) => unknown) => {
24
- cssVars: Record<string, string | undefined>;
25
- dataAttrs: Record<string, string | undefined>;
26
- };
27
- }
28
- /** Hook providing access to responsive value utilities. */
29
- export declare function useResponsiveValues(options?: UseResponsiveValuesOptions): UseResponsiveValuesResult;
30
- /**
31
- * Resolves a `Responsive<T>` value to the specific value matching the current breakpoint.
32
- *
33
- * @param value Responsive value.
34
- * @param defaultValue Fallback value if no matching breakpoint is found or if `value` is
35
- * `undefined`.
36
- * @returns The resolved value for the current breakpoint, or `defaultValue`.
37
- */
38
- export declare function useCurrentResponsiveValue<T = unknown>(value: Responsive<T> | undefined): T | undefined;
39
- export declare function useCurrentResponsiveValue<T = unknown>(value: Responsive<T> | undefined, defaultValue: T): T;
40
- /** Whether the provided value is (probably) a responsive value object. */
41
- export declare function isResponsiveValueObject<T = unknown>(value: Responsive<T>): value is Partial<Record<Breakpoint, T>>;