@orfium/ictinus 5.9.0 → 5.11.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.
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { InlineAlertProps } from './InlineAlert.types';
3
+
4
+ export declare const InlineAlert: React.ForwardRefExoticComponent<InlineAlertProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,16 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { InlineAlert } from './InlineAlert';
3
+
4
+ declare const meta: Meta<typeof InlineAlert>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof InlineAlert>;
7
+ export declare const Neutral: Story;
8
+ export declare const Informational: Story;
9
+ export declare const Error: Story;
10
+ export declare const Warning: Story;
11
+ export declare const Success: Story;
12
+ export declare const WithButtons: Story;
13
+ export declare const WithoutAction: Story;
14
+ export declare const WithoutDismiss: Story;
15
+ export declare const WithTrigger: Story;
16
+ export declare const Playground: Story;
@@ -0,0 +1,11 @@
1
+ import { Theme } from 'theme';
2
+ import { InlineAlertProps } from './InlineAlert.types';
3
+
4
+ export declare const getIconColor: (status: InlineAlertProps["status"], theme: Theme) => string;
5
+ export declare const styles: {
6
+ 'inline-alert': (props: InlineAlertProps) => (theme: Theme) => import('@emotion/react').SerializedStyles;
7
+ icon: () => (theme: Theme) => import('@emotion/react').SerializedStyles;
8
+ content: () => (theme: Theme) => import('@emotion/react').SerializedStyles;
9
+ actions: () => (theme: Theme) => import('@emotion/react').SerializedStyles;
10
+ dismiss: () => (theme: Theme) => import('@emotion/react').SerializedStyles;
11
+ };
@@ -0,0 +1,46 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { TestProps } from '../../utils/types';
3
+
4
+ /**
5
+ * Represents the possible status values for an inline alert.
6
+ */
7
+ export type AlertStatus = 'neutral' | 'informational' | 'error' | 'warning' | 'success';
8
+ export interface InlineAlertProps extends TestProps {
9
+ /**
10
+ * The status of the inline alert.
11
+ * @default 'neutral'
12
+ */
13
+ status?: AlertStatus;
14
+ /**
15
+ * The actions to be rendered within the alert.
16
+ * Can be a single ReactElement or an array of ReactElements.
17
+ * @example
18
+ * actions={[
19
+ * <Button type="tertiary" size="compact">Tertiary</Button>,
20
+ * <Button size="compact">Primary</Button>
21
+ * ]}
22
+ */
23
+ actions?: ReactElement | ReactElement[];
24
+ /**
25
+ * Whether to use alternative styling for the inline alert.
26
+ * @default false
27
+ */
28
+ isAlt?: boolean;
29
+ /**
30
+ * Callback function for the dismiss button.
31
+ * If not provided, the dismiss button will not be rendered.
32
+ */
33
+ onDismiss?(): void;
34
+ /**
35
+ * The main content of the inline alert.
36
+ */
37
+ children: ReactNode;
38
+ /**
39
+ * Whether the alert should receive focus automatically when rendered.
40
+ * Useful for scenarios where the alert is triggered programmatically.
41
+ * @default false
42
+ */
43
+ hasAutoFocus?: boolean;
44
+ /** Optional css class */
45
+ className?: string;
46
+ }
@@ -0,0 +1,2 @@
1
+ export { InlineAlert } from './InlineAlert';
2
+ export type { AlertStatus } from './InlineAlert.types';
@@ -15,5 +15,10 @@ export type InlineNotificationProps = {
15
15
  /** The data test id if needed */
16
16
  dataTestId?: TestId;
17
17
  } & Pick<NotificationActions, 'primaryCTALabel' | 'primaryCTA'>;
18
+ /**
19
+ *
20
+ * @deprecated {@link InlineNotification} has been deprecated; use {@link InlineAlert} instead.
21
+ *
22
+ */
18
23
  declare const InlineNotification: React.FC<InlineNotificationProps>;
19
24
  export default InlineNotification;
@@ -0,0 +1,80 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ export declare function useSlotProps<T>(props: T, defaultSlot?: string): any;
4
+ /**
5
+ * SlotProvider manages and provides slot props to its descendants.
6
+ * It allows for the definition and inheritance of props for named slots in a component tree.
7
+ *
8
+ * @component
9
+ * @param {Object} [props.slots={}] - An object containing slot names as keys and their corresponding props as values.
10
+ * @param {ReactNode} props.children - The child components to be wrapped by the SlotProvider.
11
+ *
12
+ * * @example
13
+ * // Register component with the useSlotProps() hook
14
+ * function Button(props) {
15
+ * props = useSlotProps(props, 'button');
16
+ *
17
+ * return (
18
+ * <button {...props}>{props.children}</button>
19
+ * );
20
+ * }
21
+ *
22
+ * function ButtonsWithPadding(props) {
23
+ * return (
24
+ * <SlotProvider slots={{ button: { style: { padding: '1rem' } } }}>
25
+ * {props.children}
26
+ * </SlotProvider>
27
+ * )
28
+ * }
29
+ *
30
+ * <ButtonsWithPadding>
31
+ * <Button>Button 1</Button> // Gets 1rem padding
32
+ * <Button>Button 2</Button> // Gets 1rem padding
33
+ * </ButtonsWithPadding>
34
+ *
35
+ * @example
36
+ * // Nested usage
37
+ * <SlotProvider slots={{ outer: { className: 'outer-class' } }}>
38
+ * <SlotProvider slots={{ inner: { className: 'inner-class' } }}>
39
+ * <Component />
40
+ * </SlotProvider>
41
+ * </SlotProvider>
42
+ *
43
+ */
44
+ export declare function SlotProvider({ slots, children }: {
45
+ slots?: object;
46
+ children: ReactNode;
47
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
48
+ /**
49
+ * ClearSlots resets the SlotContext to an empty object for its children.
50
+ * It's used to remove any inherited slot props from parent SlotProviders.
51
+ *
52
+ * @component
53
+ * @param {React.ReactNode} props.children - The child components to be wrapped by ClearSlots.
54
+ *
55
+ * @example
56
+ * // Basic usage
57
+ * <SlotProvider slots={{ text: { color: 'blue' } }}>
58
+ * <div>
59
+ * <p {...useSlotProps({}, 'text')}>This text is blue</p>
60
+ * <ClearSlots>
61
+ * <p {...useSlotProps({}, 'text')}>This text is black</p>
62
+ * </ClearSlots>
63
+ * </div>
64
+ * </SlotProvider>
65
+ *
66
+ * @example
67
+ * // Usage within nested SlotProviders
68
+ * <SlotProvider slots={{ text: { color: 'blue' } }}>
69
+ * <p {...useSlotProps({}, 'text')}>This text is blue</p>
70
+ * <ClearSlots>
71
+ * <SlotProvider slots={{ text: { color: 'red' } }}>
72
+ * <p {...useSlotProps({}, 'text')}>This text is red, not blue</p>
73
+ * </SlotProvider>
74
+ * </ClearSlots>
75
+ * </SlotProvider>
76
+ *
77
+ */
78
+ export declare function ClearSlots({ children }: {
79
+ children: ReactNode;
80
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { RefObject } from 'react';
2
+
3
+ export declare function createDOMRef<T extends HTMLElement = HTMLElement>(ref: RefObject<T | null>): T;
4
+ /**
5
+ * Create and manage a DOM reference, allowing both
6
+ * the parent and child components to access the same DOM element.
7
+ *
8
+ * @template T
9
+ * @param {React.RefObject<T>} ref - A ref object passed from the parent component.
10
+ * @returns {React.RefObject<T | null>} A new ref object that can be attached to a DOM element.
11
+ *
12
+ * @description
13
+ * This hook is useful in scenarios where you need to create a ref in a child component
14
+ * and also expose it to the parent component. It uses `useImperativeHandle` to make
15
+ * the DOM element accessible through the parent's ref.
16
+ *
17
+ * @example
18
+ * // In a child component:
19
+ * const ChildComponent = forwardRef((props, ref) => {
20
+ * const domRef = useDOMRef(ref);
21
+ * return <div ref={domRef}>Child Content</div>;
22
+ * });
23
+ *
24
+ * // In a parent component:
25
+ * const ParentComponent = () => {
26
+ * const parentRef = useRef(null);
27
+ * return <ChildComponent ref={parentRef} />;
28
+ * };
29
+ *
30
+ * @notes
31
+ * - This hook should be used in conjunction with React.forwardRef to properly pass
32
+ * the ref from the parent component.
33
+ * - The generic type T extends HTMLElement, defaulting to HTMLElement if not specified.
34
+ * - The returned ref's current property may be null if the ref hasn't been attached to an element yet.
35
+ */
36
+ export declare function useDOMRef<T extends HTMLElement = HTMLElement>(ref: RefObject<T>): RefObject<T | null>;
@@ -69,6 +69,7 @@ export * from './components/Notification/Banner';
69
69
  export { default as Snackbar } from './components/Notification/Snackbar';
70
70
  export * from './components/Notification/Snackbar';
71
71
  export * from './components/Notification/Notification';
72
+ export { InlineAlert } from './components/InlineAlert';
72
73
  export { default as Drawer } from './components/Drawer';
73
74
  export * from './components/Drawer';
74
75
  export { default as Pagination } from './components/Pagination';
@@ -0,0 +1,13 @@
1
+ import { AlertStatus } from '../../components/InlineAlert';
2
+
3
+ type Action = {
4
+ url: string;
5
+ content: string;
6
+ };
7
+ type AlertProps = {
8
+ status: AlertStatus;
9
+ action?: Action;
10
+ description: string;
11
+ };
12
+ export declare function Alert({ status, action, description }: AlertProps): import("@emotion/react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1 @@
1
+ export { Alert } from './Alert';
@@ -5,4 +5,5 @@ import { default as SubsectionHeader } from './SubsectionHeader';
5
5
  import { default as Tip } from './Tip';
6
6
  import { default as UsageGuidelines } from './UsageGuidelines';
7
7
 
8
+ export { Alert } from './Alert';
8
9
  export { UsageGuidelines, Tip, Note, Preview, SectionHeader, SubsectionHeader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orfium/ictinus",
3
- "version": "5.9.0",
3
+ "version": "5.11.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",
@@ -91,7 +91,7 @@
91
91
  "history": "^4.10.1",
92
92
  "husky": "^6.0.0",
93
93
  "identity-obj-proxy": "^3.0.0",
94
- "jsdom": "^22.1.0",
94
+ "jsdom": "^25.0.0",
95
95
  "lint-staged": "^11.0.0",
96
96
  "prettier": "^2.6.2",
97
97
  "react": "^18.2.0",