@muraldevkit/ui-toolkit 2.51.1 → 2.52.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.
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
2
  import { DSIconType } from '../svg';
3
+ /**
4
+ * This should be used to communciate error information for a specific input
5
+ */
6
+ export interface MrlFormInputError {
7
+ message: string;
8
+ }
3
9
  export type InputStates = 'disabled' | 'error' | 'read-only';
4
10
  export type InputKinds = 'default' | 'inline' | 'inline-label';
5
11
  export type InputSizes = 'default' | 'large';
@@ -2,6 +2,7 @@ export * from './select';
2
2
  export * from './select/MrlSelectItem';
3
3
  export * from './select/MrlSelectMenu';
4
4
  export * from './text-input/MrlTextInput';
5
+ export * from './text-input/MrlEditableTextInput';
5
6
  export * from './label/MrlLabel';
6
7
  export * from './textarea/MrlTextarea';
7
8
  export * from './fieldset/MrlFieldset';
@@ -0,0 +1,30 @@
1
+ import React, { InputHTMLAttributes } from 'react';
2
+ import { InputStates, MrlFormInputError } from '../../constants';
3
+ interface MrlEditableTextInputProps extends InputHTMLAttributes<HTMLInputElement> {
4
+ /** Id of the text input */
5
+ inputId: string;
6
+ /**
7
+ * Value of the label text assigned to the input.
8
+ * This is used to describe to the user what field they will be editing when interacting with the edit buton.
9
+ */
10
+ inputLabelText: string;
11
+ /** The value of the text input used to make it a controlled input */
12
+ value?: string;
13
+ /**
14
+ * The maximum number of characters that the user can enter.
15
+ * If undefined or set to "0", removes the character counter from the textarea
16
+ */
17
+ maxLength?: number;
18
+ /** Text placeholder for the text input */
19
+ placeholder?: string;
20
+ /**
21
+ * Changes the state of the input based on user permissions or actions.
22
+ */
23
+ state?: InputStates;
24
+ error?: MrlFormInputError;
25
+ 'data-qa': string;
26
+ isEditable?: boolean;
27
+ setIsEditable?: (isEditableUpdate: boolean) => void;
28
+ }
29
+ export declare const MrlEditableTextInput: React.ForwardRefExoticComponent<MrlEditableTextInputProps & React.RefAttributes<HTMLButtonElement>>;
30
+ export {};
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { DSIconType } from '../../..';
3
+ export interface MrlEditableInputRightButtonProps {
4
+ /** the action that should be executed when interacting with the icon */
5
+ action: (event: React.MouseEvent | React.KeyboardEvent) => void;
6
+ /** the icon that will be rendered */
7
+ icon: DSIconType;
8
+ /** data-qa attribute for the icon */
9
+ dataQa?: string;
10
+ /** describes the purpouse of the icon button */
11
+ label: string;
12
+ /** determines if the icon has active color or not */
13
+ hasActiveColor: boolean;
14
+ setHasActiveColor: (hasActiveColor: boolean) => void;
15
+ /** the text input value used to calculate the active style */
16
+ value?: string;
17
+ ref?: HTMLButtonElement;
18
+ }
19
+ /**
20
+ * Renders the right icon in the text input
21
+ *
22
+ * @param {MrlEditableInputRightButtonProps} props - the component props
23
+ * @returns a button element with an icon
24
+ */
25
+ export declare const MrlEditableTextInputRightButton: React.ForwardRefExoticComponent<Pick<MrlEditableInputRightButtonProps, "label" | "value" | "icon" | "dataQa" | "hasActiveColor" | "setHasActiveColor" | "action"> & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1 @@
1
+ export { MrlEditableTextInput } from './MrlEditableTextInput';
@@ -0,0 +1,30 @@
1
+ import { InputStates } from '../../constants';
2
+ type UseIsEditableReturn = {
3
+ isEditable: boolean;
4
+ isEditing: boolean;
5
+ setIsEditable: (isEditable: boolean) => void;
6
+ setIsEditing: (isEditingUpdate: boolean) => void;
7
+ };
8
+ /**
9
+ * Custom hook used to track the edit state of a text input.
10
+ *
11
+ * isEditing represents if someone has actively decided to start editing a field.
12
+ * isEditable controls if the input field can be interacted with directly.
13
+ *
14
+ * This leaves open the possibility for a field to be editable even if someone has not explicitly decided to edit it.
15
+ *
16
+ *
17
+ *
18
+ * @param {Function | undefined} param.changeHandler - optional set handler
19
+ * @param {boolean | undefined} param.initialValue - the text input initial value
20
+ * @param {InputStates | undefined} param.state - the text input state
21
+ * @param {boolean | undefined} param.value - optional control value
22
+ * @returns the isEditable, isEditing state and handler
23
+ */
24
+ export declare function useIsEditable({ changeHandler, initialValue, state, value }: {
25
+ changeHandler?: (isEditableUpdate: boolean) => void;
26
+ initialValue: boolean;
27
+ state?: InputStates;
28
+ value?: boolean;
29
+ }): UseIsEditableReturn;
30
+ export {};