@agility/plenum-ui 2.0.0-rc7 → 2.0.0-rc8
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/index.d.ts +83 -6
- package/dist/index.js +147 -0
- package/dist/index.js.map +4 -4
- package/dist/lib/tailwind.css +29 -0
- package/dist/types/stories/index.d.ts +3 -3
- package/dist/types/stories/molecules/inputs/InputField/InputField.d.ts +1 -1
- package/dist/types/stories/organisms/TextInputSelect/InputSelect.d.ts +16 -0
- package/dist/types/stories/organisms/TextInputSelect/TextInputSelect.d.ts +48 -0
- package/dist/types/stories/organisms/TextInputSelect/index.d.ts +3 -0
- package/dist/types/stories/organisms/index.d.ts +3 -2
- package/package.json +1 -1
- package/stories/index.ts +6 -2
- package/stories/molecules/inputs/InputField/InputField.tsx +1 -0
- package/stories/organisms/TextInputSelect/InputSelect.tsx +59 -0
- package/stories/organisms/TextInputSelect/TextInputSelect.stories.tsx +33 -0
- package/stories/organisms/TextInputSelect/TextInputSelect.tsx +186 -0
- package/stories/organisms/TextInputSelect/index.tsx +3 -0
- package/stories/organisms/index.ts +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -402,9 +402,9 @@ declare module '@agility/plenum-ui/stories/atoms/loaders/index' {
|
|
|
402
402
|
declare module '@agility/plenum-ui/stories/index' {
|
|
403
403
|
import { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, UnifiedIconName, IconName, FAIconName, BTNActionType, Avatar, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName } from "@agility/plenum-ui/stories/atoms/index";
|
|
404
404
|
import { ICheckboxProps, IComboboxProps, IInputFieldProps, IInputLabelProps, INestedInputButtonProps, IRadioProps, ISelectProps, ITextareaProps, IToggleSwitchProps, AcceptedInputTypes, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, TextInput, ITextInputProps } from "@agility/plenum-ui/stories/molecules/index";
|
|
405
|
-
import { IAnimatedLabelInputProps, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons } from "@agility/plenum-ui/stories/organisms/index";
|
|
406
|
-
export type { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, ICheckboxProps, IComboboxProps, IInputFieldProps, IInputLabelProps, INestedInputButtonProps, IRadioProps, ISelectProps, ITextareaProps, IToggleSwitchProps, AcceptedInputTypes, IAnimatedLabelInputProps, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, UnifiedIconName, IconName, FAIconName, BTNActionType, ITextInputProps };
|
|
407
|
-
export { Avatar, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, TextInput };
|
|
405
|
+
import { IAnimatedLabelInputProps, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect, ITextInputSelectProps } from "@agility/plenum-ui/stories/organisms/index";
|
|
406
|
+
export type { IAvatarProps, IBadgeProps, IButtonProps, ICapsuleProps, ITextInputSelectProps, IDynamicIconProps, IIconWithShadowProps, ILoaderProps, IRadialProgressProps, ICheckboxProps, IComboboxProps, IInputFieldProps, IInputLabelProps, INestedInputButtonProps, IRadioProps, ISelectProps, ITextareaProps, IToggleSwitchProps, AcceptedInputTypes, IAnimatedLabelInputProps, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, UnifiedIconName, IconName, FAIconName, BTNActionType, ITextInputProps };
|
|
407
|
+
export { Avatar, Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, Textarea, ToggleSwitch, AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, Badge, Button, Capsule, DynamicIcon, IconWithShadow, Loader, RadialProgress, isFAIcon, isHeroIcon, isTablerIcon, isUnifiedIconName, TextInput, TextInputSelect };
|
|
408
408
|
|
|
409
409
|
}
|
|
410
410
|
declare module '@agility/plenum-ui/stories/layouts/index' {
|
|
@@ -436,7 +436,7 @@ declare module '@agility/plenum-ui/stories/molecules/inputs/InputCounter/index'
|
|
|
436
436
|
}
|
|
437
437
|
declare module '@agility/plenum-ui/stories/molecules/inputs/InputField/InputField' {
|
|
438
438
|
import React from "react";
|
|
439
|
-
export type AcceptedInputTypes = "date" | "datetime-local" | "email" | "month" | "number" | "password" | "search" | "submit" | "tel" | "text" | "url";
|
|
439
|
+
export type AcceptedInputTypes = "date" | "datetime-local" | "email" | "month" | "number" | "password" | "search" | "submit" | "tel" | "text" | "url" | "currency";
|
|
440
440
|
export interface IInputFieldProps extends React.ComponentPropsWithoutRef<"input"> {
|
|
441
441
|
/** Callback on change */
|
|
442
442
|
handleChange: (value: string) => void;
|
|
@@ -1014,6 +1014,82 @@ declare module '@agility/plenum-ui/stories/organisms/FormInputWithAddons/index'
|
|
|
1014
1014
|
export type { IFormInputWithAddonsProps };
|
|
1015
1015
|
export default FormInputWithAddons;
|
|
1016
1016
|
|
|
1017
|
+
}
|
|
1018
|
+
declare module '@agility/plenum-ui/stories/organisms/TextInputSelect/InputSelect' {
|
|
1019
|
+
import { FC } from "react";
|
|
1020
|
+
export type SelectOptions = {
|
|
1021
|
+
label: string;
|
|
1022
|
+
value: string;
|
|
1023
|
+
};
|
|
1024
|
+
export interface InputSelectProps {
|
|
1025
|
+
align: "left" | "right";
|
|
1026
|
+
/** Show the CTA without Background color and a border seperator */
|
|
1027
|
+
inputOptions: SelectOptions[];
|
|
1028
|
+
/** Onclick callback */
|
|
1029
|
+
onSelectOption?(value: string): void;
|
|
1030
|
+
className?: string;
|
|
1031
|
+
isDisabled?: boolean;
|
|
1032
|
+
}
|
|
1033
|
+
/** Comment */
|
|
1034
|
+
export const InputSelect: FC<InputSelectProps>;
|
|
1035
|
+
|
|
1036
|
+
}
|
|
1037
|
+
declare module '@agility/plenum-ui/stories/organisms/TextInputSelect/TextInputSelect' {
|
|
1038
|
+
import { FC } from "react";
|
|
1039
|
+
import { AcceptedInputTypes } from "@/stories/molecules";
|
|
1040
|
+
export type SelectOptions = {
|
|
1041
|
+
label: string;
|
|
1042
|
+
value: string;
|
|
1043
|
+
};
|
|
1044
|
+
export interface ITextInputSelectProps {
|
|
1045
|
+
/** Input type*/
|
|
1046
|
+
type: AcceptedInputTypes;
|
|
1047
|
+
/** Input ID */
|
|
1048
|
+
id?: string;
|
|
1049
|
+
/** Input Name */
|
|
1050
|
+
name?: string;
|
|
1051
|
+
/** Label for the input */
|
|
1052
|
+
label?: string;
|
|
1053
|
+
/** placeholder for the input */
|
|
1054
|
+
placeholder?: string;
|
|
1055
|
+
/** Force the focus state on the input */
|
|
1056
|
+
isFocused?: boolean;
|
|
1057
|
+
/** Error state */
|
|
1058
|
+
isError?: boolean;
|
|
1059
|
+
/** If field is required */
|
|
1060
|
+
isRequired?: boolean;
|
|
1061
|
+
/** Disabled state */
|
|
1062
|
+
isDisabled?: boolean;
|
|
1063
|
+
/** Set default value */
|
|
1064
|
+
defaultValue?: string;
|
|
1065
|
+
/** Set value */
|
|
1066
|
+
value: string;
|
|
1067
|
+
/** Message shown under the text field */
|
|
1068
|
+
message?: string;
|
|
1069
|
+
/** Input character counter */
|
|
1070
|
+
isShowCounter?: boolean;
|
|
1071
|
+
/** Max length of input character */
|
|
1072
|
+
maxLength?: number;
|
|
1073
|
+
/** Select input location */
|
|
1074
|
+
selectLocation?: "left" | "right";
|
|
1075
|
+
/** Prefix */
|
|
1076
|
+
prefix?: string;
|
|
1077
|
+
/** List of options to show on the select field */
|
|
1078
|
+
inputOptions?: SelectOptions[];
|
|
1079
|
+
/** Callback on base input */
|
|
1080
|
+
onChange?(value: string): void;
|
|
1081
|
+
/** Callback on input select field */
|
|
1082
|
+
onSelectOption?(value: string): void;
|
|
1083
|
+
}
|
|
1084
|
+
const TextInputSelect: FC<ITextInputSelectProps>;
|
|
1085
|
+
export default TextInputSelect;
|
|
1086
|
+
|
|
1087
|
+
}
|
|
1088
|
+
declare module '@agility/plenum-ui/stories/organisms/TextInputSelect/index' {
|
|
1089
|
+
import TextInputSelect, { ITextInputSelectProps } from "@agility/plenum-ui/stories/organisms/TextInputSelect/TextInputSelect";
|
|
1090
|
+
export type { ITextInputSelectProps };
|
|
1091
|
+
export default TextInputSelect;
|
|
1092
|
+
|
|
1017
1093
|
}
|
|
1018
1094
|
declare module '@agility/plenum-ui/stories/organisms/index' {
|
|
1019
1095
|
import AnimatedLabelInput, { IAnimatedLabelInputProps } from "@agility/plenum-ui/stories/organisms/AnimatedLabelInput/index";
|
|
@@ -1021,8 +1097,9 @@ declare module '@agility/plenum-ui/stories/organisms/index' {
|
|
|
1021
1097
|
import Dropdown, { IDropdownClassnames, IDropdownProps, IItemProp } from "@agility/plenum-ui/stories/organisms/DropdownComponent/index";
|
|
1022
1098
|
import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "@agility/plenum-ui/stories/organisms/EmptySectionPlaceholder/index";
|
|
1023
1099
|
import FormInputWithAddons, { IFormInputWithAddonsProps } from "@agility/plenum-ui/stories/organisms/FormInputWithAddons/index";
|
|
1024
|
-
|
|
1025
|
-
export {
|
|
1100
|
+
import TextInputSelect, { ITextInputSelectProps } from "@agility/plenum-ui/stories/organisms/TextInputSelect/index";
|
|
1101
|
+
export type { IAnimatedLabelInputProps, IButtonDropdownProps, IDropdownClassnames, IDropdownProps, IEmptySectionPlaceholderProps, IItemProp, IFormInputWithAddonsProps, ITextInputSelectProps };
|
|
1102
|
+
export { AnimatedLabelInput, ButtonDropdown, Dropdown, EmptySectionPlaceholder, FormInputWithAddons, TextInputSelect };
|
|
1026
1103
|
|
|
1027
1104
|
}
|
|
1028
1105
|
declare module '@agility/plenum-ui/utils/types' {
|
package/dist/index.js
CHANGED
|
@@ -6117,6 +6117,152 @@ var FormInputWithAddons_default = FormInputWithAddons;
|
|
|
6117
6117
|
|
|
6118
6118
|
// stories/organisms/FormInputWithAddons/index.tsx
|
|
6119
6119
|
var FormInputWithAddons_default2 = FormInputWithAddons_default;
|
|
6120
|
+
|
|
6121
|
+
// stories/organisms/TextInputSelect/TextInputSelect.tsx
|
|
6122
|
+
import React25, { useEffect as useEffect6, useId as useId4, useRef as useRef3, useState as useState10 } from "react";
|
|
6123
|
+
import { default as cn25 } from "classnames";
|
|
6124
|
+
|
|
6125
|
+
// stories/organisms/TextInputSelect/InputSelect.tsx
|
|
6126
|
+
import React24, { useState as useState9 } from "react";
|
|
6127
|
+
import { default as cn24 } from "classnames";
|
|
6128
|
+
var InputSelect = ({
|
|
6129
|
+
inputOptions,
|
|
6130
|
+
onSelectOption,
|
|
6131
|
+
align = "right",
|
|
6132
|
+
className,
|
|
6133
|
+
isDisabled
|
|
6134
|
+
}) => {
|
|
6135
|
+
const [selectedOption, setSelectedOption] = useState9(inputOptions[0].value);
|
|
6136
|
+
const handleChange = (e) => {
|
|
6137
|
+
const targetValue = e.target.value;
|
|
6138
|
+
onSelectOption && onSelectOption(targetValue);
|
|
6139
|
+
setSelectedOption(targetValue);
|
|
6140
|
+
};
|
|
6141
|
+
if (!(inputOptions == null ? void 0 : inputOptions.length))
|
|
6142
|
+
return null;
|
|
6143
|
+
return /* @__PURE__ */ React24.createElement(
|
|
6144
|
+
"select",
|
|
6145
|
+
{
|
|
6146
|
+
className: cn24(
|
|
6147
|
+
"relative z-10 inline-flex items-center space-x-2 border border-gray-300 bg-white px-4 py-2 pr-7 text-sm font-medium",
|
|
6148
|
+
"focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500",
|
|
6149
|
+
align === "right" ? "-ml-px rounded-r border-l-white text-gray-700" : align === "left" ? "-mr-px rounded-l border-r-white text-gray-500 focus-within:z-10" : "",
|
|
6150
|
+
!onSelectOption ? "cursor-default" : "",
|
|
6151
|
+
className
|
|
6152
|
+
),
|
|
6153
|
+
onChange: handleChange,
|
|
6154
|
+
value: selectedOption,
|
|
6155
|
+
disabled: isDisabled
|
|
6156
|
+
},
|
|
6157
|
+
inputOptions.map((option) => /* @__PURE__ */ React24.createElement("option", { key: option.value, value: option.value }, option.label))
|
|
6158
|
+
);
|
|
6159
|
+
};
|
|
6160
|
+
|
|
6161
|
+
// stories/organisms/TextInputSelect/TextInputSelect.tsx
|
|
6162
|
+
var TextInputSelect = ({
|
|
6163
|
+
label,
|
|
6164
|
+
isFocused,
|
|
6165
|
+
isError,
|
|
6166
|
+
id: id2,
|
|
6167
|
+
name,
|
|
6168
|
+
isRequired,
|
|
6169
|
+
type,
|
|
6170
|
+
defaultValue,
|
|
6171
|
+
isDisabled,
|
|
6172
|
+
message,
|
|
6173
|
+
isShowCounter,
|
|
6174
|
+
maxLength,
|
|
6175
|
+
placeholder,
|
|
6176
|
+
inputOptions,
|
|
6177
|
+
selectLocation = "right",
|
|
6178
|
+
prefix,
|
|
6179
|
+
onChange,
|
|
6180
|
+
onSelectOption,
|
|
6181
|
+
value: externalValue
|
|
6182
|
+
}) => {
|
|
6183
|
+
const [isFocus, setIsFocus] = useState10(Boolean(isFocused));
|
|
6184
|
+
const [value, setValue] = useState10(defaultValue || "");
|
|
6185
|
+
const inputRef = useRef3(null);
|
|
6186
|
+
const uniqueID = useId4();
|
|
6187
|
+
if (!id2)
|
|
6188
|
+
id2 = `select-${uniqueID}`;
|
|
6189
|
+
if (!name)
|
|
6190
|
+
name = id2;
|
|
6191
|
+
useEffect6(() => {
|
|
6192
|
+
setValue(externalValue);
|
|
6193
|
+
}, [externalValue]);
|
|
6194
|
+
useEffect6(() => {
|
|
6195
|
+
const input = inputRef.current;
|
|
6196
|
+
if (!input || isFocus === void 0 || isFocused === void 0 || isDisabled)
|
|
6197
|
+
return;
|
|
6198
|
+
if (isFocus || isFocused) {
|
|
6199
|
+
input.focus();
|
|
6200
|
+
} else {
|
|
6201
|
+
input.blur();
|
|
6202
|
+
}
|
|
6203
|
+
}, [isFocus, isFocused]);
|
|
6204
|
+
useEffect6(() => {
|
|
6205
|
+
const input = inputRef.current;
|
|
6206
|
+
if (!input || defaultValue === void 0 || defaultValue === "")
|
|
6207
|
+
return;
|
|
6208
|
+
}, [defaultValue]);
|
|
6209
|
+
const handleInputFocus = () => {
|
|
6210
|
+
setIsFocus(true);
|
|
6211
|
+
};
|
|
6212
|
+
const handleInputBlur = () => {
|
|
6213
|
+
setIsFocus(false);
|
|
6214
|
+
};
|
|
6215
|
+
const labelStyles = cn25("block inline-block font-medium transition-all text-sm text-gray-700 mb-1", {
|
|
6216
|
+
"text-red-500 bg-white": isError
|
|
6217
|
+
});
|
|
6218
|
+
const discriptionStyles = cn25("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError });
|
|
6219
|
+
return /* @__PURE__ */ React25.createElement("div", null, label && /* @__PURE__ */ React25.createElement("label", { htmlFor: id2, className: labelStyles }, label, isRequired && /* @__PURE__ */ React25.createElement("span", { className: "text-red-500" }, " *")), /* @__PURE__ */ React25.createElement("div", { className: "flex" }, (inputOptions == null ? void 0 : inputOptions.length) && selectLocation === "left" && /* @__PURE__ */ React25.createElement(
|
|
6220
|
+
InputSelect,
|
|
6221
|
+
{
|
|
6222
|
+
inputOptions,
|
|
6223
|
+
align: "left",
|
|
6224
|
+
onSelectOption,
|
|
6225
|
+
className: cn25(isError ? "border-red-500" : ""),
|
|
6226
|
+
isDisabled
|
|
6227
|
+
}
|
|
6228
|
+
), /* @__PURE__ */ React25.createElement("div", { className: "relative flex-grow focus-within:z-20" }, prefix && /* @__PURE__ */ React25.createElement("div", { className: "pointer-events-none pr-10 absolute inset-y-0 left-0 flex items-center pl-3" }, /* @__PURE__ */ React25.createElement("span", { className: "text-gray-500 sm:text-sm" }, prefix)), /* @__PURE__ */ React25.createElement(
|
|
6229
|
+
InputField_default2,
|
|
6230
|
+
{
|
|
6231
|
+
onFocus: handleInputFocus,
|
|
6232
|
+
onBlur: handleInputBlur,
|
|
6233
|
+
handleChange: (v) => onChange && onChange(v),
|
|
6234
|
+
ref: inputRef,
|
|
6235
|
+
type,
|
|
6236
|
+
name,
|
|
6237
|
+
id: id2,
|
|
6238
|
+
className: cn25(
|
|
6239
|
+
"w-full border border-gray-300 py-2 px-3 text-sm font-normal leading-5",
|
|
6240
|
+
"focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 sm:text-sm",
|
|
6241
|
+
selectLocation === "right" ? `rounded-l` : `rounded-r`,
|
|
6242
|
+
isError ? "border-red-500" : "",
|
|
6243
|
+
prefix ? `pl-7` : ""
|
|
6244
|
+
),
|
|
6245
|
+
isDisabled,
|
|
6246
|
+
defaultValue,
|
|
6247
|
+
value,
|
|
6248
|
+
maxLength,
|
|
6249
|
+
placeholder
|
|
6250
|
+
}
|
|
6251
|
+
)), (inputOptions == null ? void 0 : inputOptions.length) && selectLocation === "right" && /* @__PURE__ */ React25.createElement(
|
|
6252
|
+
InputSelect,
|
|
6253
|
+
{
|
|
6254
|
+
inputOptions,
|
|
6255
|
+
align: "right",
|
|
6256
|
+
onSelectOption,
|
|
6257
|
+
isDisabled,
|
|
6258
|
+
className: cn25(isError ? "border-red-500" : "")
|
|
6259
|
+
}
|
|
6260
|
+
)), /* @__PURE__ */ React25.createElement("div", { className: "flex flex-row space-x-3" }, /* @__PURE__ */ React25.createElement("div", { className: "grow" }, message && /* @__PURE__ */ React25.createElement("span", { className: discriptionStyles }, message)), isShowCounter && /* @__PURE__ */ React25.createElement("div", { className: "shrink-0" }, /* @__PURE__ */ React25.createElement(InputCounter_default, { current: Number(value == null ? void 0 : value.length), limit: maxLength }))));
|
|
6261
|
+
};
|
|
6262
|
+
var TextInputSelect_default = TextInputSelect;
|
|
6263
|
+
|
|
6264
|
+
// stories/organisms/TextInputSelect/index.tsx
|
|
6265
|
+
var TextInputSelect_default2 = TextInputSelect_default;
|
|
6120
6266
|
export {
|
|
6121
6267
|
AnimatedLabelInput_default2 as AnimatedLabelInput,
|
|
6122
6268
|
Avatar_default2 as Avatar,
|
|
@@ -6139,6 +6285,7 @@ export {
|
|
|
6139
6285
|
radio_default as Radio,
|
|
6140
6286
|
select_default as Select,
|
|
6141
6287
|
TextInput_default2 as TextInput,
|
|
6288
|
+
TextInputSelect_default2 as TextInputSelect,
|
|
6142
6289
|
textArea_default as Textarea,
|
|
6143
6290
|
toggleSwitch_default as ToggleSwitch,
|
|
6144
6291
|
isFAIcon,
|