@eightshift/ui-components 1.5.0 → 1.5.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.
|
@@ -6,8 +6,10 @@ import { Switch } from "../toggle/switch.js";
|
|
|
6
6
|
import { TriggeredPopover } from "../popover/popover.js";
|
|
7
7
|
import { ButtonGroup } from "../button/button.js";
|
|
8
8
|
import { ToggleButton } from "../toggle-button/toggle-button.js";
|
|
9
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
9
10
|
import { Spacer } from "../spacer/spacer.js";
|
|
10
11
|
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
12
|
+
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
11
13
|
/**
|
|
12
14
|
* A component that provides a nice way to toggle a component on and off, and display its content in an expandable panel.
|
|
13
15
|
*
|
|
@@ -19,8 +21,12 @@ import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
|
19
21
|
* @param {boolean} props.useComponent - Whether the component is used. If `false`, the content is hidden.
|
|
20
22
|
* @param {Function} props.onChange - Function to run when the toggle state changes.
|
|
21
23
|
* @param {boolean} [props.noUseToggle] - If `true`, the toggle is not displayed.
|
|
24
|
+
* @param {boolean} [props.noExpandButton] - If `true`, the expand button is not shown.
|
|
25
|
+
* @param {boolean} [props.noLabel] - If `true`, the label is not shown.
|
|
26
|
+
* @param {boolean} [props.noUseToggle] - If `true`, the toggle is not displayed.
|
|
22
27
|
* @param {boolean} [props.expandButtonDisabled] - If `true`, the expand button is disabled.
|
|
23
28
|
* @param {boolean} [props.controlOnly] - If `true`, only the control is displayed.
|
|
29
|
+
* @param {boolean} [props.hideUseToggleOnExpand] - If `true`, and the component is display in a variant where it can be expanded, the use toggle will hide when the component is expanded.
|
|
24
30
|
* @param {string} [props.contentClassName] - Classes to pass to the content container.
|
|
25
31
|
* @param {ComponentToggleDesign} [props.design='default'] - Design of the component.
|
|
26
32
|
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
@@ -48,9 +54,12 @@ const ComponentToggle = (props) => {
|
|
|
48
54
|
subtitle,
|
|
49
55
|
useComponent,
|
|
50
56
|
onChange,
|
|
57
|
+
noLabel,
|
|
51
58
|
noUseToggle,
|
|
52
|
-
|
|
59
|
+
noExpandButton,
|
|
53
60
|
controlOnly,
|
|
61
|
+
expandButtonDisabled,
|
|
62
|
+
hideUseToggleOnExpand,
|
|
54
63
|
contentClassName = "es-uic-space-y-2.5",
|
|
55
64
|
design = "default",
|
|
56
65
|
hidden
|
|
@@ -58,7 +67,7 @@ const ComponentToggle = (props) => {
|
|
|
58
67
|
if (hidden) {
|
|
59
68
|
return null;
|
|
60
69
|
}
|
|
61
|
-
if (controlOnly) {
|
|
70
|
+
if (controlOnly || noLabel && noUseToggle && noExpandButton) {
|
|
62
71
|
return children;
|
|
63
72
|
}
|
|
64
73
|
if (design.startsWith("compact")) {
|
|
@@ -70,7 +79,7 @@ const ComponentToggle = (props) => {
|
|
|
70
79
|
ToggleButton,
|
|
71
80
|
{
|
|
72
81
|
icon: hasIcon && (icon ?? icons.componentGeneric),
|
|
73
|
-
tooltip: hasIcon && label,
|
|
82
|
+
tooltip: hasIcon && !noLabel && label,
|
|
74
83
|
selected: useComponent,
|
|
75
84
|
onChange,
|
|
76
85
|
children: hasLabel && label
|
|
@@ -94,12 +103,42 @@ const ComponentToggle = (props) => {
|
|
|
94
103
|
)
|
|
95
104
|
] });
|
|
96
105
|
}
|
|
106
|
+
if (noExpandButton) {
|
|
107
|
+
return /* @__PURE__ */ jsxs(
|
|
108
|
+
BaseControl,
|
|
109
|
+
{
|
|
110
|
+
icon: icon ?? icons.componentGeneric,
|
|
111
|
+
label: !noLabel && label,
|
|
112
|
+
subtitle,
|
|
113
|
+
actions: !noUseToggle && /* @__PURE__ */ jsx(
|
|
114
|
+
Switch,
|
|
115
|
+
{
|
|
116
|
+
checked: useComponent,
|
|
117
|
+
onChange
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
disabled: !useComponent || expandButtonDisabled,
|
|
121
|
+
children: [
|
|
122
|
+
noUseToggle && children,
|
|
123
|
+
!noUseToggle && /* @__PURE__ */ jsx(
|
|
124
|
+
AnimatedVisibility,
|
|
125
|
+
{
|
|
126
|
+
visible: useComponent,
|
|
127
|
+
className: contentClassName,
|
|
128
|
+
children
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
97
135
|
return /* @__PURE__ */ jsx(
|
|
98
136
|
Expandable,
|
|
99
137
|
{
|
|
100
138
|
icon: icon ?? icons.componentGeneric,
|
|
101
|
-
label,
|
|
139
|
+
label: !noLabel && label,
|
|
102
140
|
subtitle,
|
|
141
|
+
keepActionsOnExpand: !hideUseToggleOnExpand,
|
|
103
142
|
actions: !noUseToggle && /* @__PURE__ */ jsx(
|
|
104
143
|
Switch,
|
|
105
144
|
{
|
|
@@ -16,7 +16,7 @@ const multiValueLabelStyles = "es-uic-select-none";
|
|
|
16
16
|
const multiValueRemoveStyles = "hover:es-uic-bg-red-500/15 hover:es-uic-text-red-900 es-uic-text-gray-500 es-uic-rounded es-uic-p-0.5 [&>svg]:es-uic-size-3.5 [&>svg]:es-uic-stroke-[1.5] es-uic-transition";
|
|
17
17
|
const clearIndicatorStyles = "es-uic-text-gray-500 es-uic-p-1 es-uic-rounded-md hover:bg-red-50 hover:text-red-800 es-uic-transition";
|
|
18
18
|
const dropdownIndicatorStyles = "es-uic-text-gray-500 es-uic-px-1 group-hover:es-uic-text-black [&>svg]:es-uic-transition-transform [&>svg]:es-uic-duration-500 [&>svg]:es-uic-size-5.5";
|
|
19
|
-
const menuStyles = "es-uic-rounded-md es-uic-border es-uic-border-gray-200 es-uic-bg-white es-uic-shadow-lg es-uic-mt-1 es-uic-text-sm es-uic-overflow-x-hidden";
|
|
19
|
+
const menuStyles = "es-uic-relative es-uic-z-50 es-uic-rounded-md es-uic-border es-uic-border-gray-200 es-uic-bg-white es-uic-shadow-lg es-uic-mt-1 es-uic-text-sm es-uic-overflow-x-hidden";
|
|
20
20
|
const optionStyles = {
|
|
21
21
|
base: "es-uic-p-2 !es-uic-flex es-uic-items-center es-uic-gap-1.5 es-uic-text-gray-800 es-uic-rounded [&>svg]:es-uic-size-5 [&>svg]:es-uic-text-gray-500 es-uic-transition es-uic-mx-1 first:es-uic-mt-1 last:es-uic-mb-1 !es-uic-w-auto es-uic-min-h-9",
|
|
22
22
|
focus: "es-uic-bg-gray-100 active:es-uic-bg-teal-700/15",
|