@muraldevkit/ui-toolkit 1.15.8 → 1.16.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.
- package/dist/components/form/constants.d.ts +2 -1
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/text-input/MrlTextInput/MrlTextInput.d.ts +36 -0
- package/dist/components/form/text-input/MrlTextInput/MrlTextInputRightIcon.d.ts +23 -0
- package/dist/components/form/text-input/MrlTextInput/index.d.ts +1 -0
- package/dist/components/form/text-input/MrlTextInput/useActiveColor.d.ts +13 -0
- package/dist/index.js +1 -1
- package/dist/styles/MrlTextInput/module.scss +97 -0
- package/dist/styles/MrlTextInput/variables.scss +6 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export type InputStates = 'disabled' | 'error';
|
|
2
3
|
export type InputKinds = 'default' | 'inline';
|
|
3
4
|
export type InputSizes = 'default' | 'large';
|
|
@@ -43,7 +44,7 @@ export interface StaticIconConfig {
|
|
|
43
44
|
theme?: string;
|
|
44
45
|
}
|
|
45
46
|
export interface RightActionConfig extends StaticIconConfig {
|
|
46
|
-
action: (event: MouseEvent) => void;
|
|
47
|
+
action: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
47
48
|
label: string;
|
|
48
49
|
}
|
|
49
50
|
export declare const allowedLabelValues: {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AttrsObject } from '../../../../utils';
|
|
3
|
+
import { RightActionConfig, InputStates } from '../../constants';
|
|
4
|
+
/**
|
|
5
|
+
* @todo - we need to add static icon support for right
|
|
6
|
+
*/
|
|
7
|
+
interface MrlTextInputProps {
|
|
8
|
+
/** Applies additional HTML attributes to the text input element */
|
|
9
|
+
attrs?: AttrsObject;
|
|
10
|
+
/** Additional function to be run when the input's value is cleared */
|
|
11
|
+
hookClear?: () => void;
|
|
12
|
+
/** Id of the text input */
|
|
13
|
+
inputId: string;
|
|
14
|
+
/** The value of the text input used to make it a controlled input */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** Text placeholder for the text input */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Changes the state of the input based on user permissions or actions.
|
|
20
|
+
*/
|
|
21
|
+
state?: InputStates;
|
|
22
|
+
/** Configures a static icon to persistently display on the left side of the input */
|
|
23
|
+
persistIcon?: Record<string, unknown>;
|
|
24
|
+
/** Configures an icon to the right side of the input */
|
|
25
|
+
dynamicIcon?: RightActionConfig;
|
|
26
|
+
/** Preset for setting up a clearable input via a right icon */
|
|
27
|
+
isClearable?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Allows the user to input plain text
|
|
31
|
+
*
|
|
32
|
+
* @param {MrlTextInputProps} props - the component props
|
|
33
|
+
* @returns a text input element
|
|
34
|
+
*/
|
|
35
|
+
export declare function MrlTextInput({ attrs, inputId, isClearable, dynamicIcon, hookClear, persistIcon, placeholder, state, value }: MrlTextInputProps): JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MrlTextInputRightIconProps {
|
|
3
|
+
/** the action that should be executed when interacting with the icon */
|
|
4
|
+
action: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
5
|
+
/** the icon that will be rendered */
|
|
6
|
+
icon: Record<string, unknown>;
|
|
7
|
+
/** data-qa attribute for the icon */
|
|
8
|
+
dataQa?: string;
|
|
9
|
+
/** describes the purpouse of the icon button */
|
|
10
|
+
label: string;
|
|
11
|
+
/** determines if the icon has active color or not */
|
|
12
|
+
hasActiveColor: boolean;
|
|
13
|
+
setHasActiveColor: (hasActiveColor: boolean) => void;
|
|
14
|
+
/** the text input value used to calculate the active style */
|
|
15
|
+
value?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Renders the right icon in the text input
|
|
19
|
+
*
|
|
20
|
+
* @param {MrlTextInputRightIconProps} props - the component props
|
|
21
|
+
* @returns a button element with an icon
|
|
22
|
+
*/
|
|
23
|
+
export declare function MrlTextInputRightIcon({ action, dataQa, hasActiveColor, icon, label, setHasActiveColor, value }: MrlTextInputRightIconProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MrlTextInput } from './MrlTextInput';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InputStates } from '../../constants';
|
|
2
|
+
type useActiveColorReturn = {
|
|
3
|
+
hasActiveColor: boolean;
|
|
4
|
+
setHasActiveColor: (hasActiveColor: boolean) => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Custom hook used to track the active color state of the text input
|
|
8
|
+
*
|
|
9
|
+
* @param {InputStates | undefined} state - the text input state
|
|
10
|
+
* @returns the hasActiveColor state and handler
|
|
11
|
+
*/
|
|
12
|
+
export declare function useActiveColor(state?: InputStates): useActiveColorReturn;
|
|
13
|
+
export {};
|