@agility/plenum-ui 2.3.3 → 2.3.4
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 +6 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/tailwind.css +5 -0
- package/dist/types/stories/molecules/inputs/select/Select.d.ts +6 -0
- package/package.json +1 -1
- package/stories/molecules/inputs/select/Select.stories.tsx +19 -0
- package/stories/molecules/inputs/select/Select.tsx +31 -3
package/dist/tailwind.css
CHANGED
|
@@ -73528,6 +73528,11 @@ select {
|
|
|
73528
73528
|
color: rgb(131 24 67 / 0.95);
|
|
73529
73529
|
}
|
|
73530
73530
|
|
|
73531
|
+
.text-primary-700 {
|
|
73532
|
+
--tw-text-opacity: 1;
|
|
73533
|
+
color: rgb(109 40 217 / var(--tw-text-opacity, 1));
|
|
73534
|
+
}
|
|
73535
|
+
|
|
73531
73536
|
.text-purple-100 {
|
|
73532
73537
|
--tw-text-opacity: 1;
|
|
73533
73538
|
color: rgb(222 204 246 / var(--tw-text-opacity, 1));
|
|
@@ -7,6 +7,11 @@ export interface ISimpleSelectOptions {
|
|
|
7
7
|
description?: string;
|
|
8
8
|
caption?: string;
|
|
9
9
|
}
|
|
10
|
+
interface LabelAction {
|
|
11
|
+
label: string;
|
|
12
|
+
onClick: () => void;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
10
15
|
export interface ISelectProps {
|
|
11
16
|
/** Label */
|
|
12
17
|
label?: string;
|
|
@@ -33,6 +38,7 @@ export interface ISelectProps {
|
|
|
33
38
|
placeholder?: string;
|
|
34
39
|
dropdownMaxHeight?: number;
|
|
35
40
|
dropdownMaxWidth?: number;
|
|
41
|
+
labelAction?: LabelAction;
|
|
36
42
|
}
|
|
37
43
|
declare const Select: React.FC<ISelectProps>;
|
|
38
44
|
export default Select;
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { action } from "@storybook/addon-actions";
|
|
2
3
|
import Select from "./Select";
|
|
3
4
|
|
|
4
5
|
const meta: Meta<typeof Select> = {
|
|
@@ -90,6 +91,24 @@ export const ManyOptions: TStory = {
|
|
|
90
91
|
}
|
|
91
92
|
};
|
|
92
93
|
|
|
94
|
+
export const WithLabelAction: TStory = {
|
|
95
|
+
args: {
|
|
96
|
+
label: "Batch",
|
|
97
|
+
id: "select-label-action",
|
|
98
|
+
name: "select-label-action",
|
|
99
|
+
isRequired: true,
|
|
100
|
+
options: [
|
|
101
|
+
{ label: "Batch 1", value: "batch-1" },
|
|
102
|
+
{ label: "Batch 2", value: "batch-2" },
|
|
103
|
+
{ label: "Batch 3", value: "batch-3" }
|
|
104
|
+
],
|
|
105
|
+
labelAction: {
|
|
106
|
+
label: "Add new batch",
|
|
107
|
+
onClick: action("labelAction clicked")
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
93
112
|
export const DefaultSelectDarkBG: TStory = {
|
|
94
113
|
args: {
|
|
95
114
|
label: "Label",
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ComboboxOption
|
|
12
12
|
} from "@headlessui/react";
|
|
13
13
|
import { Paragraph } from "@/stories/atoms/Typography/Paragraph";
|
|
14
|
+
import { Label } from "@/stories/atoms/Typography/Label";
|
|
14
15
|
|
|
15
16
|
export interface ISimpleSelectOptions {
|
|
16
17
|
label: string;
|
|
@@ -20,6 +21,12 @@ export interface ISimpleSelectOptions {
|
|
|
20
21
|
caption?: string;
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
interface LabelAction {
|
|
25
|
+
label: string;
|
|
26
|
+
onClick: () => void;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
export interface ISelectProps {
|
|
24
31
|
/** Label */
|
|
25
32
|
label?: string;
|
|
@@ -46,6 +53,7 @@ export interface ISelectProps {
|
|
|
46
53
|
placeholder?: string;
|
|
47
54
|
dropdownMaxHeight?: number;
|
|
48
55
|
dropdownMaxWidth?: number;
|
|
56
|
+
labelAction?: LabelAction;
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
const Select: React.FC<ISelectProps> = ({
|
|
@@ -65,7 +73,8 @@ const Select: React.FC<ISelectProps> = ({
|
|
|
65
73
|
inputRef,
|
|
66
74
|
placeholder = "Select",
|
|
67
75
|
dropdownMaxHeight = 240,
|
|
68
|
-
dropdownMaxWidth = 240
|
|
76
|
+
dropdownMaxWidth = 240,
|
|
77
|
+
labelAction
|
|
69
78
|
}) => {
|
|
70
79
|
const uniqueID = useId();
|
|
71
80
|
if (!id) id = `select-${uniqueID}`;
|
|
@@ -101,7 +110,25 @@ const Select: React.FC<ISelectProps> = ({
|
|
|
101
110
|
|
|
102
111
|
return (
|
|
103
112
|
<div className={wrapperStyle}>
|
|
104
|
-
{label
|
|
113
|
+
{(label || labelAction) && (
|
|
114
|
+
<div className="flex items-center justify-between">
|
|
115
|
+
{label && (
|
|
116
|
+
<InputLabel
|
|
117
|
+
id={`${id}-label`}
|
|
118
|
+
label={label}
|
|
119
|
+
isRequired={isRequired}
|
|
120
|
+
noMarginBottom={!!labelAction}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
{labelAction && (
|
|
124
|
+
<button type="button" onClick={labelAction.onClick}>
|
|
125
|
+
<Label size="sm" className={cn("text-primary-700", labelAction.className)}>
|
|
126
|
+
{labelAction.label}
|
|
127
|
+
</Label>
|
|
128
|
+
</button>
|
|
129
|
+
)}
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
105
132
|
|
|
106
133
|
<HeadlessCombobox value={selectedOption} onChange={handleChange} disabled={isDisabled} immediate by="value">
|
|
107
134
|
<div ref={containerRef} className="relative w-full">
|
|
@@ -177,7 +204,8 @@ const Select: React.FC<ISelectProps> = ({
|
|
|
177
204
|
title={option.label}
|
|
178
205
|
onMouseEnter={(e) => {
|
|
179
206
|
const el = e.currentTarget;
|
|
180
|
-
if (el.scrollWidth <= el.clientWidth)
|
|
207
|
+
if (el.scrollWidth <= el.clientWidth)
|
|
208
|
+
el.removeAttribute("title");
|
|
181
209
|
}}
|
|
182
210
|
onMouseLeave={(e) => {
|
|
183
211
|
e.currentTarget.setAttribute("title", option.label);
|