@ostack.tech/ui 0.10.1 → 0.10.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.
@@ -5,7 +5,7 @@ import { IconButton } from '../IconButton';
5
5
  /** Properties provided to the fallback element. */
6
6
  export interface FallbackProps {
7
7
  /** Error that occurred. */
8
- error: any;
8
+ error: unknown;
9
9
  /**
10
10
  * Function which, when called, rerenders the boundary `children`.
11
11
  *
@@ -10,9 +10,8 @@ export type FeedbackProps = ComponentPropsWithoutRef<"div" | "li"> & {
10
10
  */
11
11
  asChild?: boolean;
12
12
  /**
13
- * Type of feedback.
14
- *
15
- * @default error
13
+ * Type of feedback. The default type defaults to the matching status of the
14
+ * associated field control, or to `"error"` otherwise.
16
15
  */
17
16
  type?: FeedbackType;
18
17
  /** Text prefixed to the feedback to be announced by assistive technologies. */
@@ -10,7 +10,7 @@ export interface FieldProps extends ComponentPropsWithoutRef<"div"> {
10
10
  }
11
11
  /**
12
12
  * The `Field` component acts as a container that associates a form control with
13
- * a label, helper text, and validation feedback.
13
+ * a label, helper text, and/or validation feedback.
14
14
  *
15
15
  * Use a `Label` to identify the control, a `HelperText` to provide additional
16
16
  * guidance or descriptions, and `Feedback` to display error, warning, or
@@ -33,14 +33,13 @@ export interface FieldProps extends ComponentPropsWithoutRef<"div"> {
33
33
  * Example usage:
34
34
  *
35
35
  * ```tsx
36
- * import { Field, HelperText, Label, Input } from "@ostack.tech/ui";
36
+ * import { Field, Label, Input } from "@ostack.tech/ui";
37
37
  *
38
38
  * function UsernameField() {
39
39
  * return (
40
40
  * <Field>
41
41
  * <Label>Username</Label>
42
42
  * <Input />
43
- * <HelperText>May only contain alphanumeric characters.</HelperText>
44
43
  * </Field>
45
44
  * );
46
45
  * }
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
+ import { ControlStatus } from '../../utils/control.ts';
2
3
  /** Value of the field context. */
3
4
  export type FieldContextValue = FieldStore;
4
5
  /** State of the field. */
@@ -8,6 +9,7 @@ export interface FieldState {
8
9
  controlFocused: boolean;
9
10
  controlHasCode: boolean;
10
11
  controlRequired: boolean;
12
+ controlStatus?: ControlStatus;
11
13
  label?: ReactNode;
12
14
  labelId?: string;
13
15
  descriptionIds: string[];
@@ -51,6 +53,8 @@ export declare function useFieldControlTagName(): string | undefined;
51
53
  export declare function useFieldControlFocused(): boolean | undefined;
52
54
  /** Hook exposing whether the field's control is required. */
53
55
  export declare function useFieldControlRequired(): boolean | undefined;
56
+ /** Hook exposing the field's control status. */
57
+ export declare function useFieldControlStatus(): ControlStatus | undefined;
54
58
  /** Hook exposing the `children` of the field's label. */
55
59
  export declare function useFieldLabel(): ReactNode;
56
60
  /** Hook exposing the field label's id. */
@@ -60,7 +64,7 @@ export declare function useFieldDescriptionIds(): string[] | undefined;
60
64
  /** Hook exposing the field's error message ids. */
61
65
  export declare function useFieldErrorMessageIds(): string[] | undefined;
62
66
  /** Hook that makes a field aware of its control's information. */
63
- export declare function useSetFieldControl(controlId: string | undefined, controlTagName: string | undefined, controlCodeId: string | undefined, controlHasCode?: boolean | undefined, controlRequired?: boolean | undefined): {
67
+ export declare function useSetFieldControl(controlId: string | undefined, controlTagName: string | undefined, controlCodeId: string | undefined, controlHasCode?: boolean | undefined, controlRequired?: boolean | undefined, controlStatus?: ControlStatus | undefined): {
64
68
  generatedId: string;
65
69
  controlId: string;
66
70
  codeId: string | undefined;
@@ -1,7 +1,7 @@
1
1
  import { ErrorInfo } from 'react';
2
2
  /** Value of the error reporting context. */
3
3
  export interface ErrorReportingContextValue {
4
- onError: (error: Error, info?: ErrorInfo) => void;
4
+ onError: (error: unknown, info?: ErrorInfo) => void;
5
5
  }
6
6
  /** Error reporting context. */
7
7
  export declare const ErrorReportingContext: import('react').Context<ErrorReportingContextValue | null>;
@@ -1,2 +1,2 @@
1
1
  /** Hook used to report an error. */
2
- export declare function useErrorReporter(): (error: Error, info?: import('react').ErrorInfo) => void;
2
+ export declare function useErrorReporter(): (error: unknown, info?: import('react').ErrorInfo) => void;
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.10.1",
4
+ "version": "0.10.3",
5
5
  "homepage": "https://ui.ostack.tech/",
6
6
  "author": {
7
7
  "name": "Opensoft",
@@ -47,7 +47,7 @@
47
47
  "from-exponential": "^1.1.1",
48
48
  "radix-ui": "^1.4.3",
49
49
  "react-day-picker": "^9.13.0",
50
- "react-error-boundary": "^6.0.3",
50
+ "react-error-boundary": "^6.1.0",
51
51
  "react-number-format": "^5.4.4",
52
52
  "react-to-print": "^3.2.0",
53
53
  "tinykeys": "^3.0.0"
@@ -1,7 +1,7 @@
1
1
  @use "../../scss/base-variables" as *;
2
2
  @use "../../scss/utils/spacing" as *;
3
3
 
4
- $heading-margin-top: 0 !default;
4
+ $heading-margin-top: null !default;
5
5
  $heading-margin-bottom: spacing(2) !default;
6
6
  $heading-font-weight: $font-weight-bold !default;
7
7
 
@@ -6,8 +6,14 @@
6
6
  .#{$prefix}heading {
7
7
  $heading: &;
8
8
 
9
- margin-top: $heading-margin-top;
10
- margin-bottom: $heading-margin-bottom;
9
+ margin-top: 0;
10
+ margin-bottom: 0;
11
+ &:not(:first-child) {
12
+ margin-top: $heading-margin-top;
13
+ }
14
+ &:not(:last-child) {
15
+ margin-bottom: $heading-margin-bottom;
16
+ }
11
17
  font-weight: $heading-font-weight;
12
18
 
13
19
  // Levels