@eightshift/ui-components 1.4.1 → 1.4.2
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/assets/style.css +1 -1
- package/dist/components/expandable/expandable.js +1 -1
- package/dist/components/link-input/link-input.js +3 -2
- package/dist/components/number-picker/number-picker.js +1 -0
- package/dist/components/repeater/repeater-item.js +6 -21
- package/dist/components/repeater/repeater.js +69 -21
- package/package.json +1 -1
|
@@ -65,7 +65,7 @@ const Expandable = (props) => {
|
|
|
65
65
|
"div",
|
|
66
66
|
{
|
|
67
67
|
className: clsx(
|
|
68
|
-
"es-uic-w-full es-uic-rounded-lg es-uic-border es-uic-border-gray-300 es-uic-border-opacity-0 es-uic-text-sm es-uic-transition",
|
|
68
|
+
"es-uic-w-full es-uic-rounded-lg es-uic-border es-uic-border-gray-300 es-uic-border-opacity-0 es-uic-text-sm es-uic-transition focus:es-uic-outline-none",
|
|
69
69
|
isOpen && "es-uic-border-opacity-100 es-uic-shadow-lg",
|
|
70
70
|
className
|
|
71
71
|
),
|
|
@@ -1853,9 +1853,10 @@ const LinkInput = (props) => {
|
|
|
1853
1853
|
{
|
|
1854
1854
|
"aria-label": __("URL suggestions", "eightshift-ui-components"),
|
|
1855
1855
|
className: ({ isEntering, isExiting }) => clsx(
|
|
1856
|
-
"es-uic-rounded-md es-uic-border es-uic-border-gray-200 es-uic-bg-white es-uic-shadow-lg es-uic-outline-none
|
|
1856
|
+
"es-uic-rounded-md es-uic-border es-uic-border-gray-200 es-uic-bg-white es-uic-shadow-lg es-uic-outline-none",
|
|
1857
1857
|
isEntering && "es-uic-outline es-uic-animate-in es-uic-fade-in-0 es-uic-slide-in-from-top-2 es-uic-fill-mode-forwards",
|
|
1858
|
-
isExiting && "es-uic-outline es-uic-animate-out es-uic-fade-out-0 es-uic-slide-out-to-top-2 es-uic-fill-mode-forwards"
|
|
1858
|
+
isExiting && "es-uic-outline es-uic-animate-out es-uic-fade-out-0 es-uic-slide-out-to-top-2 es-uic-fill-mode-forwards",
|
|
1859
|
+
!shouldShowSuggestions && suggestionList.items.length < 1 && "es-uic-invisible"
|
|
1859
1860
|
),
|
|
1860
1861
|
style: {
|
|
1861
1862
|
width: `${(_a = triggerRef.current) == null ? void 0 : _a.offsetWidth}px`
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React__default, { forwardRef, useRef, createContext, useState, cloneElement } from "react";
|
|
3
|
+
import { _ as __ } from "../../default-i18n-BqWys-1G.js";
|
|
3
4
|
import { $ as $a049562f99e7db0e$export$f9c6924e160136d1, a as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4 } from "../../Group-WZgNv9RE.js";
|
|
4
5
|
import { $ as $3985021b0ad6602f$export$37fb8590cf2c088c, a as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-CaS4qmLb.js";
|
|
5
6
|
import { a as $01b77f81d0f07f68$export$75b6ee27786ba447, $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-yZgqvhXc.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx,
|
|
1
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button } from "../button/button.js";
|
|
3
3
|
import { icons } from "../../icons/icons.js";
|
|
4
4
|
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
@@ -27,8 +27,8 @@ import { RepeaterContext } from "./repeater-context.js";
|
|
|
27
27
|
*/
|
|
28
28
|
const RepeaterItem = (props) => {
|
|
29
29
|
const { children, icon, label, subtitle, "aria-label": ariaLabel, className, actions, textValue, expandDisabled, ...rest } = props;
|
|
30
|
-
const { canDelete, handleOpenChange,
|
|
31
|
-
return /* @__PURE__ */ jsx(
|
|
30
|
+
const { canDelete, handleOpenChange, deleteItem, isDragSource } = useContext(RepeaterContext);
|
|
31
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
32
32
|
Expandable,
|
|
33
33
|
{
|
|
34
34
|
disabled: canDelete,
|
|
@@ -39,21 +39,7 @@ const RepeaterItem = (props) => {
|
|
|
39
39
|
labelClassName: className,
|
|
40
40
|
onOpenChange: (isOpen) => handleOpenChange(isOpen),
|
|
41
41
|
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
-
|
|
43
|
-
Button,
|
|
44
|
-
{
|
|
45
|
-
size: "small",
|
|
46
|
-
className: clsx(
|
|
47
|
-
"es-uic-h-6 es-uic-w-4 !es-uic-text-gray-500 es-uic-opacity-50 focus:es-uic-opacity-100",
|
|
48
|
-
(isAnyPanelOpen || canDelete) && "es-uic-pointer-events-none es-uic-invisible !es-uic-cursor-default"
|
|
49
|
-
),
|
|
50
|
-
type: "ghost",
|
|
51
|
-
icon: icons.reorderGrabberV,
|
|
52
|
-
tooltip: !isDragSource && __("Re-order", "eightshift-ui-components"),
|
|
53
|
-
forwardedRef: handleRef,
|
|
54
|
-
disabled: isPanelOpen
|
|
55
|
-
}
|
|
56
|
-
),
|
|
42
|
+
actions,
|
|
57
43
|
/* @__PURE__ */ jsx(
|
|
58
44
|
Button,
|
|
59
45
|
{
|
|
@@ -65,13 +51,12 @@ const RepeaterItem = (props) => {
|
|
|
65
51
|
onPress: () => deleteItem(),
|
|
66
52
|
className: "es-uic-translate-x-px"
|
|
67
53
|
}
|
|
68
|
-
)
|
|
69
|
-
actions
|
|
54
|
+
)
|
|
70
55
|
] }),
|
|
71
56
|
noFocusHandling: true,
|
|
72
57
|
children
|
|
73
58
|
}
|
|
74
|
-
);
|
|
59
|
+
) });
|
|
75
60
|
};
|
|
76
61
|
export {
|
|
77
62
|
RepeaterItem
|
|
@@ -8,6 +8,7 @@ import { AnimatedVisibility } from "../animated-visibility/animated-visibility.j
|
|
|
8
8
|
import { ToggleButton } from "../toggle-button/toggle-button.js";
|
|
9
9
|
import { r as reactDomExports } from "../../index-BTCzc3zb.js";
|
|
10
10
|
import { RepeaterContext } from "./repeater-context.js";
|
|
11
|
+
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
11
12
|
var i = Symbol.for("preact-signals");
|
|
12
13
|
function t() {
|
|
13
14
|
if (!(s > 1)) {
|
|
@@ -5121,12 +5122,12 @@ const Repeater = (props) => {
|
|
|
5121
5122
|
},
|
|
5122
5123
|
size: "small",
|
|
5123
5124
|
icon: icons.add,
|
|
5124
|
-
className: "[&>svg]:es-uic-size-4",
|
|
5125
|
+
className: clsx("[&>svg]:es-uic-size-4", !hideEmptyState && items.length < 1 && "es-uic-invisible"),
|
|
5125
5126
|
tooltip: __("Add item", "eightshift-ui-components"),
|
|
5126
5127
|
disabled: addDisabled || canDelete
|
|
5127
5128
|
}
|
|
5128
5129
|
),
|
|
5129
|
-
addButton && addButton({
|
|
5130
|
+
addButton && /* @__PURE__ */ jsx("div", { className: clsx(!hideEmptyState && items.length < 1 && "es-uic-invisible"), children: addButton({
|
|
5130
5131
|
addItem: (additional = {}) => {
|
|
5131
5132
|
const newItem = { id: `${itemIdBase}${items.length + 1}`, ...addDefaultItem, ...additional };
|
|
5132
5133
|
setItems((items2) => [...items2, newItem]);
|
|
@@ -5136,7 +5137,7 @@ const Repeater = (props) => {
|
|
|
5136
5137
|
}
|
|
5137
5138
|
},
|
|
5138
5139
|
disabled: addDisabled || canDelete
|
|
5139
|
-
})
|
|
5140
|
+
}) })
|
|
5140
5141
|
] }),
|
|
5141
5142
|
className: "es-uic-w-full",
|
|
5142
5143
|
children: [
|
|
@@ -5188,31 +5189,48 @@ const Repeater = (props) => {
|
|
|
5188
5189
|
value: {
|
|
5189
5190
|
...item,
|
|
5190
5191
|
index,
|
|
5191
|
-
handleRef,
|
|
5192
5192
|
canDelete,
|
|
5193
5193
|
deleteItem: () => {
|
|
5194
5194
|
setItems([...items].filter((i2) => i2.id !== item.id));
|
|
5195
5195
|
onChange([...items].filter((i2) => i2.id !== item.id));
|
|
5196
|
-
onAfterItemRemove
|
|
5196
|
+
if (onAfterItemRemove) {
|
|
5197
|
+
onAfterItemRemove(item);
|
|
5198
|
+
}
|
|
5197
5199
|
},
|
|
5198
|
-
isPanelOpen: (isPanelOpen == null ? void 0 : isPanelOpen[item.id]) ?? false,
|
|
5199
|
-
isAnyPanelOpen,
|
|
5200
5200
|
handleOpenChange: (isOpen) => setIsPanelOpen((data) => ({ ...data, [item.id]: isOpen })),
|
|
5201
5201
|
isDragSource
|
|
5202
5202
|
},
|
|
5203
|
-
children: /* @__PURE__ */
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5203
|
+
children: /* @__PURE__ */ jsxs("div", { className: "es-uic-relative", children: [
|
|
5204
|
+
/* @__PURE__ */ jsx(
|
|
5205
|
+
Button,
|
|
5206
|
+
{
|
|
5207
|
+
size: "small",
|
|
5208
|
+
className: clsx(
|
|
5209
|
+
"es-uic-absolute es-uic-bottom-0 es-uic-left-0 es-uic-top-0 es-uic-my-auto es-uic-h-6 es-uic-w-4 -es-uic-translate-x-full !es-uic-text-gray-500 es-uic-opacity-50 focus:es-uic-opacity-100",
|
|
5210
|
+
(isAnyPanelOpen || canDelete) && "es-uic-pointer-events-none es-uic-invisible !es-uic-cursor-default"
|
|
5211
|
+
),
|
|
5212
|
+
type: "ghost",
|
|
5213
|
+
icon: icons.reorderGrabberV,
|
|
5214
|
+
tooltip: !isDragSource && __("Re-order", "eightshift-ui-components"),
|
|
5215
|
+
forwardedRef: handleRef
|
|
5216
|
+
}
|
|
5217
|
+
),
|
|
5218
|
+
children({
|
|
5219
|
+
...item,
|
|
5220
|
+
updateData: (newValue) => {
|
|
5221
|
+
setItems((items2) => items2.map((i2) => i2.id === item.id ? { ...i2, ...newValue } : i2));
|
|
5222
|
+
onChange(items);
|
|
5223
|
+
},
|
|
5224
|
+
itemIndex: index,
|
|
5225
|
+
deleteItem: () => {
|
|
5226
|
+
setItems([...items].filter((i2) => i2.id !== item.id));
|
|
5227
|
+
onChange([...items].filter((i2) => i2.id !== item.id));
|
|
5228
|
+
if (onAfterItemRemove) {
|
|
5229
|
+
onAfterItemRemove(item);
|
|
5230
|
+
}
|
|
5231
|
+
}
|
|
5232
|
+
})
|
|
5233
|
+
] })
|
|
5216
5234
|
},
|
|
5217
5235
|
item.id
|
|
5218
5236
|
)
|
|
@@ -5223,7 +5241,37 @@ const Repeater = (props) => {
|
|
|
5223
5241
|
) }),
|
|
5224
5242
|
/* @__PURE__ */ jsxs(AnimatedVisibility, { visible: items.length < 1, children: [
|
|
5225
5243
|
emptyState,
|
|
5226
|
-
!hideEmptyState && /* @__PURE__ */
|
|
5244
|
+
!hideEmptyState && /* @__PURE__ */ jsxs("div", { className: "es-uic-flex es-uic-flex-col es-uic-items-center es-uic-gap-2 es-uic-rounded-md es-uic-border es-uic-border-dashed es-uic-border-gray-300 es-uic-p-4 es-uic-text-center es-uic-text-sm es-uic-text-gray-400", children: [
|
|
5245
|
+
!addButton && /* @__PURE__ */ jsx(
|
|
5246
|
+
Button,
|
|
5247
|
+
{
|
|
5248
|
+
onPress: () => {
|
|
5249
|
+
const newItem = { id: `${itemIdBase}${items.length + 1}`, ...addDefaultItem };
|
|
5250
|
+
setItems((items2) => [...items2, newItem]);
|
|
5251
|
+
onChange(items);
|
|
5252
|
+
if (onAfterItemAdd) {
|
|
5253
|
+
onAfterItemAdd(newItem);
|
|
5254
|
+
}
|
|
5255
|
+
},
|
|
5256
|
+
size: "small",
|
|
5257
|
+
icon: icons.add,
|
|
5258
|
+
className: "[&>svg]:es-uic-size-4",
|
|
5259
|
+
disabled: addDisabled,
|
|
5260
|
+
children: __("Add item", "eightshift-ui-components")
|
|
5261
|
+
}
|
|
5262
|
+
),
|
|
5263
|
+
addButton && !hideEmptyState && addButton({
|
|
5264
|
+
addItem: (additional = {}) => {
|
|
5265
|
+
const newItem = { id: `${itemIdBase}${items.length + 1}`, ...addDefaultItem, ...additional };
|
|
5266
|
+
setItems((items2) => [...items2, newItem]);
|
|
5267
|
+
onChange(items);
|
|
5268
|
+
if (onAfterItemAdd) {
|
|
5269
|
+
onAfterItemAdd(newItem);
|
|
5270
|
+
}
|
|
5271
|
+
},
|
|
5272
|
+
disabled: addDisabled || canDelete
|
|
5273
|
+
})
|
|
5274
|
+
] })
|
|
5227
5275
|
] })
|
|
5228
5276
|
]
|
|
5229
5277
|
}
|