runeforge 0.0.31 → 0.0.32
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.
|
@@ -208,6 +208,7 @@
|
|
|
208
208
|
label: action.label,
|
|
209
209
|
icon: action.icon,
|
|
210
210
|
toggle: action.toggle,
|
|
211
|
+
class: action.class,
|
|
211
212
|
condition: action.condition,
|
|
212
213
|
run: (item: T) => onAction?.(action, item)
|
|
213
214
|
})),
|
|
@@ -234,10 +235,12 @@
|
|
|
234
235
|
<div class="flex justify-end items-center gap-1">
|
|
235
236
|
{#each rowActions as action (action.label)}
|
|
236
237
|
{#if action.condition?.(item) ?? true}
|
|
238
|
+
{@const resolvedClass =
|
|
239
|
+
typeof action.class === 'function' ? action.class(item) : action.class}
|
|
237
240
|
{#if action.toggle}
|
|
238
241
|
<input
|
|
239
242
|
type="checkbox"
|
|
240
|
-
class={['toggle toggle-sm',
|
|
243
|
+
class={['toggle toggle-sm', resolvedClass]}
|
|
241
244
|
title={action.label}
|
|
242
245
|
aria-label={action.label}
|
|
243
246
|
checked={action.toggle(item)}
|
|
@@ -251,7 +254,7 @@
|
|
|
251
254
|
{@const Icon = action.icon}
|
|
252
255
|
<Button
|
|
253
256
|
variant="ghost"
|
|
254
|
-
class={['btn-xs',
|
|
257
|
+
class={['btn-xs', resolvedClass]}
|
|
255
258
|
title={action.label}
|
|
256
259
|
aria-label={action.label}
|
|
257
260
|
onclick={(e) => {
|
package/dist/types/crud.d.ts
CHANGED
|
@@ -75,6 +75,11 @@ export interface CustomAction<T extends object = Record<string, unknown>> {
|
|
|
75
75
|
* flips once the underlying item's data actually changes — e.g. after
|
|
76
76
|
* the action's modal confirms and the list reloads. */
|
|
77
77
|
toggle?: (item: T) => boolean;
|
|
78
|
+
/** Extra class(es) on the row action's button/switch — e.g. to color a
|
|
79
|
+
* `toggle` by the item's own state (`toggle-success`/`toggle-error`).
|
|
80
|
+
* Pass a function to resolve it per item; a plain string applies to
|
|
81
|
+
* every row alike. */
|
|
82
|
+
class?: string | ((item: T) => string);
|
|
78
83
|
endpoint?: string;
|
|
79
84
|
condition?: (item: T) => boolean;
|
|
80
85
|
/** Renders as a modal-like panel when the action runs. Mutually exclusive
|
|
@@ -89,7 +94,8 @@ export interface RowAction<T extends object = Record<string, unknown>> {
|
|
|
89
94
|
icon?: any;
|
|
90
95
|
/** See `CustomAction.toggle` — same controlled-switch rendering. */
|
|
91
96
|
toggle?: (item: T) => boolean;
|
|
92
|
-
class
|
|
97
|
+
/** See `CustomAction.class`. */
|
|
98
|
+
class?: string | ((item: T) => string);
|
|
93
99
|
condition?: (item: T) => boolean;
|
|
94
100
|
run: (item: T) => void;
|
|
95
101
|
}
|