@eightshift/ui-components 1.4.1 → 1.4.3
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 +72 -28
- package/package.json +2 -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)) {
|
|
@@ -5085,6 +5086,9 @@ const Repeater = (props) => {
|
|
|
5085
5086
|
if (canDelete && items.length < (minItems ?? 1)) {
|
|
5086
5087
|
setCanDelete(false);
|
|
5087
5088
|
}
|
|
5089
|
+
useEffect(() => {
|
|
5090
|
+
setItems(fixIds(rawItems));
|
|
5091
|
+
}, [rawItems]);
|
|
5088
5092
|
if (hidden) {
|
|
5089
5093
|
return null;
|
|
5090
5094
|
}
|
|
@@ -5113,30 +5117,28 @@ const Repeater = (props) => {
|
|
|
5113
5117
|
{
|
|
5114
5118
|
onPress: () => {
|
|
5115
5119
|
const newItem = { id: `${itemIdBase}${items.length + 1}`, ...addDefaultItem };
|
|
5116
|
-
|
|
5117
|
-
onChange(items);
|
|
5120
|
+
onChange([...items, newItem]);
|
|
5118
5121
|
if (onAfterItemAdd) {
|
|
5119
5122
|
onAfterItemAdd(newItem);
|
|
5120
5123
|
}
|
|
5121
5124
|
},
|
|
5122
5125
|
size: "small",
|
|
5123
5126
|
icon: icons.add,
|
|
5124
|
-
className: "[&>svg]:es-uic-size-4",
|
|
5127
|
+
className: clsx("[&>svg]:es-uic-size-4", !hideEmptyState && items.length < 1 && "es-uic-invisible"),
|
|
5125
5128
|
tooltip: __("Add item", "eightshift-ui-components"),
|
|
5126
5129
|
disabled: addDisabled || canDelete
|
|
5127
5130
|
}
|
|
5128
5131
|
),
|
|
5129
|
-
addButton && addButton({
|
|
5132
|
+
addButton && /* @__PURE__ */ jsx("div", { className: clsx(!hideEmptyState && items.length < 1 && "es-uic-invisible"), children: addButton({
|
|
5130
5133
|
addItem: (additional = {}) => {
|
|
5131
5134
|
const newItem = { id: `${itemIdBase}${items.length + 1}`, ...addDefaultItem, ...additional };
|
|
5132
|
-
|
|
5133
|
-
onChange(items);
|
|
5135
|
+
onChange([...items, newItem]);
|
|
5134
5136
|
if (onAfterItemAdd) {
|
|
5135
5137
|
onAfterItemAdd(newItem);
|
|
5136
5138
|
}
|
|
5137
5139
|
},
|
|
5138
5140
|
disabled: addDisabled || canDelete
|
|
5139
|
-
})
|
|
5141
|
+
}) })
|
|
5140
5142
|
] }),
|
|
5141
5143
|
className: "es-uic-w-full",
|
|
5142
5144
|
children: [
|
|
@@ -5172,8 +5174,7 @@ const Repeater = (props) => {
|
|
|
5172
5174
|
if (event.canceled) {
|
|
5173
5175
|
return;
|
|
5174
5176
|
}
|
|
5175
|
-
|
|
5176
|
-
onChange(items);
|
|
5177
|
+
onChange(move([...items], source, target));
|
|
5177
5178
|
},
|
|
5178
5179
|
children: items.map((item, index) => /* @__PURE__ */ jsx(
|
|
5179
5180
|
SortableItem,
|
|
@@ -5188,31 +5189,46 @@ const Repeater = (props) => {
|
|
|
5188
5189
|
value: {
|
|
5189
5190
|
...item,
|
|
5190
5191
|
index,
|
|
5191
|
-
handleRef,
|
|
5192
5192
|
canDelete,
|
|
5193
5193
|
deleteItem: () => {
|
|
5194
|
-
setItems([...items].filter((i2) => i2.id !== item.id));
|
|
5195
5194
|
onChange([...items].filter((i2) => i2.id !== item.id));
|
|
5196
|
-
onAfterItemRemove
|
|
5195
|
+
if (onAfterItemRemove) {
|
|
5196
|
+
onAfterItemRemove(item);
|
|
5197
|
+
}
|
|
5197
5198
|
},
|
|
5198
|
-
isPanelOpen: (isPanelOpen == null ? void 0 : isPanelOpen[item.id]) ?? false,
|
|
5199
|
-
isAnyPanelOpen,
|
|
5200
5199
|
handleOpenChange: (isOpen) => setIsPanelOpen((data) => ({ ...data, [item.id]: isOpen })),
|
|
5201
5200
|
isDragSource
|
|
5202
5201
|
},
|
|
5203
|
-
children: /* @__PURE__ */
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5202
|
+
children: /* @__PURE__ */ jsxs("div", { className: "es-uic-relative", children: [
|
|
5203
|
+
/* @__PURE__ */ jsx(
|
|
5204
|
+
Button,
|
|
5205
|
+
{
|
|
5206
|
+
size: "small",
|
|
5207
|
+
className: clsx(
|
|
5208
|
+
"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",
|
|
5209
|
+
(isAnyPanelOpen || canDelete) && "es-uic-pointer-events-none es-uic-invisible !es-uic-cursor-default"
|
|
5210
|
+
),
|
|
5211
|
+
type: "ghost",
|
|
5212
|
+
icon: icons.reorderGrabberV,
|
|
5213
|
+
tooltip: !isDragSource && __("Re-order", "eightshift-ui-components"),
|
|
5214
|
+
forwardedRef: handleRef
|
|
5215
|
+
}
|
|
5216
|
+
),
|
|
5217
|
+
children({
|
|
5218
|
+
...item,
|
|
5219
|
+
updateData: (newValue) => {
|
|
5220
|
+
const updated = [...items].map((i2) => i2.id === item.id ? { ...i2, ...newValue } : i2);
|
|
5221
|
+
onChange(updated);
|
|
5222
|
+
},
|
|
5223
|
+
itemIndex: index,
|
|
5224
|
+
deleteItem: () => {
|
|
5225
|
+
onChange([...items].filter((i2) => i2.id !== item.id));
|
|
5226
|
+
if (onAfterItemRemove) {
|
|
5227
|
+
onAfterItemRemove(item);
|
|
5228
|
+
}
|
|
5229
|
+
}
|
|
5230
|
+
})
|
|
5231
|
+
] })
|
|
5216
5232
|
},
|
|
5217
5233
|
item.id
|
|
5218
5234
|
)
|
|
@@ -5223,7 +5239,35 @@ const Repeater = (props) => {
|
|
|
5223
5239
|
) }),
|
|
5224
5240
|
/* @__PURE__ */ jsxs(AnimatedVisibility, { visible: items.length < 1, children: [
|
|
5225
5241
|
emptyState,
|
|
5226
|
-
!hideEmptyState && /* @__PURE__ */
|
|
5242
|
+
!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: [
|
|
5243
|
+
!addButton && /* @__PURE__ */ jsx(
|
|
5244
|
+
Button,
|
|
5245
|
+
{
|
|
5246
|
+
onPress: () => {
|
|
5247
|
+
const newItem = { id: `${itemIdBase}${items.length + 1}`, ...addDefaultItem };
|
|
5248
|
+
onChange([...items, newItem]);
|
|
5249
|
+
if (onAfterItemAdd) {
|
|
5250
|
+
onAfterItemAdd(newItem);
|
|
5251
|
+
}
|
|
5252
|
+
},
|
|
5253
|
+
size: "small",
|
|
5254
|
+
icon: icons.add,
|
|
5255
|
+
className: "[&>svg]:es-uic-size-4",
|
|
5256
|
+
disabled: addDisabled,
|
|
5257
|
+
children: __("Add item", "eightshift-ui-components")
|
|
5258
|
+
}
|
|
5259
|
+
),
|
|
5260
|
+
addButton && !hideEmptyState && addButton({
|
|
5261
|
+
addItem: (additional = {}) => {
|
|
5262
|
+
const newItem = { id: `${itemIdBase}${items.length + 1}`, ...addDefaultItem, ...additional };
|
|
5263
|
+
onChange([...items, newItem]);
|
|
5264
|
+
if (onAfterItemAdd) {
|
|
5265
|
+
onAfterItemAdd(newItem);
|
|
5266
|
+
}
|
|
5267
|
+
},
|
|
5268
|
+
disabled: addDisabled || canDelete
|
|
5269
|
+
})
|
|
5270
|
+
] })
|
|
5227
5271
|
] })
|
|
5228
5272
|
]
|
|
5229
5273
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eightshift/ui-components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"tailwindcss": "^3.4.7",
|
|
86
86
|
"tailwindcss-animate": "^1.0.7",
|
|
87
87
|
"tailwindcss-react-aria-components": "^1.1.4",
|
|
88
|
+
"tailwindcss-scoped-preflight": "^3.4.3",
|
|
88
89
|
"vite": "^5.3.5",
|
|
89
90
|
"vite-plugin-lib-inject-css": "^2.1.1"
|
|
90
91
|
},
|