@wordrhyme/auto-crud 1.8.1 → 1.8.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/README.md +24 -2
- package/dist/index.cjs +51 -58
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +32 -20
- package/dist/position--p6kJnYA.js +56 -0
- package/dist/position-BlO0bPw6.cjs +109 -0
- package/dist/position-DoBV7yB6.d.cts +29 -0
- package/dist/position-mYekVBBH.d.ts +29 -0
- package/dist/position.cjs +6 -0
- package/dist/position.d.cts +2 -0
- package/dist/position.d.ts +2 -0
- package/dist/position.js +3 -0
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -803,7 +803,7 @@ type ToolbarBuiltinActionItem = ActionMeta & {
|
|
|
803
803
|
type ToolbarCustomActionItem = ActionMeta & {
|
|
804
804
|
type: 'custom';
|
|
805
805
|
component: React.ReactNode | ((context: AutoCrudToolbarContext) => React.ReactNode);
|
|
806
|
-
position?:
|
|
806
|
+
position?: ActionPosition; // start/end 仅无内置项时生效;也支持 { anchor, side }
|
|
807
807
|
};
|
|
808
808
|
|
|
809
809
|
interface AutoCrudToolbarContext {
|
|
@@ -911,6 +911,28 @@ crudActions.register({
|
|
|
911
911
|
`order` 不再重排同一插件数组内的显示顺序。内置属性覆盖仍沿用原有的 action `order`、`ownerId`、注册序优先级,最后一个配置生效。
|
|
912
912
|
使用 `order` 排列同一插件操作的旧调用方,应把数组调整为所需顺序。最终权限过滤只移除不可用的内置操作,不改变其余操作顺序或授予权限。
|
|
913
913
|
|
|
914
|
+
### 统一位置契约
|
|
915
|
+
|
|
916
|
+
AutoCrud action 和 WordRhyme PluginSlot 共用 `ActionPosition`:`"start"`、`"end"`,或 `{ anchor, side: "before" | "after" }`。类型、schema、位置匹配和锚点排序从不依赖 React 的 `@wordrhyme/auto-crud/position` 导出。
|
|
917
|
+
|
|
918
|
+
`positionActions(ownerActions, fills)` 合并拥有方按钮和扩展数组:`start` fills 放在数组前,`end` 或未指定位置的 fills 放在数组后,相对位置按基础按钮锚点插入。AutoCrud 和 PluginSlot 共用此解析器。原有 action 数组及 start/end 排列规则保持不变。指定锚点时,在原有合并、覆盖和隐藏之后定位,`order` 按升序排列同一锚点的 fills。AutoCrud 使用合并后基础 action 的 `id` 作为锚点;原生按钮未设置 `id` 时使用 `type`。合并后的动作列表不存在锚点时,不显示依赖它的扩展;最终权限过滤继续沿用已有行为。
|
|
919
|
+
|
|
920
|
+
```tsx
|
|
921
|
+
crudActions.register({
|
|
922
|
+
targetId: 'com.wordrhyme.shop.products',
|
|
923
|
+
zone: 'toolbar',
|
|
924
|
+
ownerId: 'com.wordrhyme.sync',
|
|
925
|
+
actions: [
|
|
926
|
+
{
|
|
927
|
+
type: 'custom',
|
|
928
|
+
component: SyncButton,
|
|
929
|
+
position: { anchor: 'create', side: 'before' },
|
|
930
|
+
order: 30,
|
|
931
|
+
},
|
|
932
|
+
],
|
|
933
|
+
});
|
|
934
|
+
```
|
|
935
|
+
|
|
914
936
|
---
|
|
915
937
|
|
|
916
938
|
## 🎬 行操作配置
|
|
@@ -1005,7 +1027,7 @@ type RowCustomActionItem<T> = ActionMeta & {
|
|
|
1005
1027
|
component?:
|
|
1006
1028
|
| React.ReactNode
|
|
1007
1029
|
| ((context: AutoCrudRowActionContext<T>) => React.ReactNode);
|
|
1008
|
-
position?:
|
|
1030
|
+
position?: ActionPosition; // start/end 仅无内置项时生效;也支持 { anchor, side }
|
|
1009
1031
|
separator?: boolean;
|
|
1010
1032
|
variant?: 'default' | 'destructive';
|
|
1011
1033
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1,58 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
1
|
+
const require_position = require('./position-BlO0bPw6.cjs');
|
|
24
2
|
let react = require("react");
|
|
25
|
-
react = __toESM(react);
|
|
3
|
+
react = require_position.__toESM(react);
|
|
26
4
|
let lucide_react = require("lucide-react");
|
|
27
|
-
lucide_react = __toESM(lucide_react);
|
|
5
|
+
lucide_react = require_position.__toESM(lucide_react);
|
|
28
6
|
let __tanstack_react_table = require("@tanstack/react-table");
|
|
29
|
-
__tanstack_react_table = __toESM(__tanstack_react_table);
|
|
7
|
+
__tanstack_react_table = require_position.__toESM(__tanstack_react_table);
|
|
30
8
|
let __wordrhyme_shadcn = require("@wordrhyme/shadcn");
|
|
31
|
-
__wordrhyme_shadcn = __toESM(__wordrhyme_shadcn);
|
|
9
|
+
__wordrhyme_shadcn = require_position.__toESM(__wordrhyme_shadcn);
|
|
32
10
|
let clsx = require("clsx");
|
|
33
|
-
clsx = __toESM(clsx);
|
|
11
|
+
clsx = require_position.__toESM(clsx);
|
|
34
12
|
let tailwind_merge = require("tailwind-merge");
|
|
35
|
-
tailwind_merge = __toESM(tailwind_merge);
|
|
13
|
+
tailwind_merge = require_position.__toESM(tailwind_merge);
|
|
36
14
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
react_jsx_runtime = __toESM(react_jsx_runtime);
|
|
15
|
+
react_jsx_runtime = require_position.__toESM(react_jsx_runtime);
|
|
38
16
|
let nanoid = require("nanoid");
|
|
39
|
-
nanoid = __toESM(nanoid);
|
|
17
|
+
nanoid = require_position.__toESM(nanoid);
|
|
40
18
|
let __wordrhyme_shadcn_ui = require("@wordrhyme/shadcn-ui");
|
|
41
|
-
__wordrhyme_shadcn_ui = __toESM(__wordrhyme_shadcn_ui);
|
|
19
|
+
__wordrhyme_shadcn_ui = require_position.__toESM(__wordrhyme_shadcn_ui);
|
|
42
20
|
let __wordrhyme_ui = require("@wordrhyme/ui");
|
|
43
|
-
__wordrhyme_ui = __toESM(__wordrhyme_ui);
|
|
21
|
+
__wordrhyme_ui = require_position.__toESM(__wordrhyme_ui);
|
|
44
22
|
let zod = require("zod");
|
|
45
|
-
zod = __toESM(zod);
|
|
23
|
+
zod = require_position.__toESM(zod);
|
|
46
24
|
let __wordrhyme_formily_shadcn = require("@wordrhyme/formily-shadcn");
|
|
47
|
-
__wordrhyme_formily_shadcn = __toESM(__wordrhyme_formily_shadcn);
|
|
25
|
+
__wordrhyme_formily_shadcn = require_position.__toESM(__wordrhyme_formily_shadcn);
|
|
48
26
|
let __formily_core = require("@formily/core");
|
|
49
|
-
__formily_core = __toESM(__formily_core);
|
|
27
|
+
__formily_core = require_position.__toESM(__formily_core);
|
|
50
28
|
let __formily_reactive = require("@formily/reactive");
|
|
51
|
-
__formily_reactive = __toESM(__formily_reactive);
|
|
29
|
+
__formily_reactive = require_position.__toESM(__formily_reactive);
|
|
52
30
|
let sonner = require("sonner");
|
|
53
|
-
sonner = __toESM(sonner);
|
|
31
|
+
sonner = require_position.__toESM(sonner);
|
|
54
32
|
let __tanstack_react_query = require("@tanstack/react-query");
|
|
55
|
-
__tanstack_react_query = __toESM(__tanstack_react_query);
|
|
33
|
+
__tanstack_react_query = require_position.__toESM(__tanstack_react_query);
|
|
56
34
|
|
|
57
35
|
//#region src/lib/utils.ts
|
|
58
36
|
function cn(...inputs) {
|
|
@@ -4112,7 +4090,7 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
|
|
|
4112
4090
|
{ type: "export" },
|
|
4113
4091
|
{ type: "delete" }
|
|
4114
4092
|
]) : actions;
|
|
4115
|
-
|
|
4093
|
+
let resolvedActions = configuredActions?.filter((action$1) => !action$1.hidden);
|
|
4116
4094
|
if (configuredActions === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
4117
4095
|
renderBuiltinAction({ type: "batchUpdate" }),
|
|
4118
4096
|
extraActions,
|
|
@@ -4120,7 +4098,20 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
|
|
|
4120
4098
|
renderBuiltinAction({ type: "delete" })
|
|
4121
4099
|
] });
|
|
4122
4100
|
if (!resolvedActions || resolvedActions.length === 0) return null;
|
|
4123
|
-
|
|
4101
|
+
let hasBuiltin = resolvedActions.some((action$1) => action$1.type !== "custom");
|
|
4102
|
+
if (resolvedActions.some((action$1) => "position" in action$1 && typeof action$1.position === "object")) if (!hasBuiltin) {
|
|
4103
|
+
resolvedActions = require_position.positionActions([
|
|
4104
|
+
{ type: "batchUpdate" },
|
|
4105
|
+
...extraActions ? [{
|
|
4106
|
+
type: "custom",
|
|
4107
|
+
component: extraActions
|
|
4108
|
+
}] : [],
|
|
4109
|
+
...showDefaultExport ? [{ type: "export" }] : [],
|
|
4110
|
+
{ type: "delete" }
|
|
4111
|
+
], resolvedActions);
|
|
4112
|
+
hasBuiltin = true;
|
|
4113
|
+
} else resolvedActions = require_position.positionActions(resolvedActions);
|
|
4114
|
+
if (!hasBuiltin) {
|
|
4124
4115
|
const startNodes = resolvedActions.filter(isBatchCustomAction).filter((action$1) => action$1.position === "start").map((action$1, index$1) => renderCustomAction(action$1, index$1));
|
|
4125
4116
|
const endNodes = resolvedActions.filter(isBatchCustomAction).filter((action$1) => action$1.position !== "start").map((action$1, index$1) => renderCustomAction(action$1, index$1));
|
|
4126
4117
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
@@ -6273,15 +6264,18 @@ function unregisterOwnerActions(ownerId, options = {}, shouldNotify = true) {
|
|
|
6273
6264
|
if (changed && shouldNotify) notify();
|
|
6274
6265
|
}
|
|
6275
6266
|
function sortEntries(left, right) {
|
|
6276
|
-
const orderDiff = left
|
|
6267
|
+
const orderDiff = require_position.compareOrder(left, right);
|
|
6277
6268
|
if (orderDiff !== 0) return orderDiff;
|
|
6278
6269
|
const ownerDiff = left.ownerId.localeCompare(right.ownerId);
|
|
6279
6270
|
if (ownerDiff !== 0) return ownerDiff;
|
|
6280
6271
|
return left.seq - right.seq;
|
|
6281
6272
|
}
|
|
6282
6273
|
function withoutRegistryMeta(action$1) {
|
|
6283
|
-
const { id, order,...rest } = action$1;
|
|
6284
|
-
return
|
|
6274
|
+
const { id, order, position,...rest } = action$1;
|
|
6275
|
+
return {
|
|
6276
|
+
...rest,
|
|
6277
|
+
...typeof position === "string" ? { position } : {}
|
|
6278
|
+
};
|
|
6285
6279
|
}
|
|
6286
6280
|
function isCustomAction$1(action$1) {
|
|
6287
6281
|
return action$1.type === "custom";
|
|
@@ -6296,12 +6290,11 @@ function resolveActions$1(targetId, zone, ownerActions) {
|
|
|
6296
6290
|
if (isCustomAction$1(action$1) && action$1.id && !isMaskedCustom(action$1)) customOverrides.set(action$1.id, entry);
|
|
6297
6291
|
}
|
|
6298
6292
|
const ownerCustomIds = new Set(ownerActions.flatMap((action$1) => isCustomAction$1(action$1) && action$1.id ? [action$1.id] : []));
|
|
6299
|
-
const baseActions = ownerActions.filter((action$1) => !action$1.hidden && !isMaskedCustom(action$1)).map((action$1) =>
|
|
6293
|
+
const baseActions = ownerActions.filter((action$1) => !action$1.hidden && !isMaskedCustom(action$1)).map((action$1) => ({ ...isCustomAction$1(action$1) && action$1.id ? customOverrides.get(action$1.id)?.action ?? action$1 : action$1 }));
|
|
6300
6294
|
const isReplacedCustom = ({ action: action$1, seq: seq$1 }) => isCustomAction$1(action$1) && Boolean(action$1.id && (ownerCustomIds.has(action$1.id) || customOverrides.get(action$1.id)?.seq !== seq$1));
|
|
6301
|
-
if (registered.length === 0) return baseActions;
|
|
6295
|
+
if (registered.length === 0) return require_position.positionActions(baseActions).map(withoutRegistryMeta);
|
|
6302
6296
|
const nextActions = [...baseActions];
|
|
6303
|
-
const
|
|
6304
|
-
const endCustomActions = [];
|
|
6297
|
+
const extraActions = [];
|
|
6305
6298
|
const groups = /* @__PURE__ */ new Map();
|
|
6306
6299
|
for (const entry of registered) {
|
|
6307
6300
|
if (isMaskedCustom(entry.action)) continue;
|
|
@@ -6315,7 +6308,7 @@ function resolveActions$1(targetId, zone, ownerActions) {
|
|
|
6315
6308
|
if (existingIndex >= 0) nextActions.splice(existingIndex, 1);
|
|
6316
6309
|
continue;
|
|
6317
6310
|
}
|
|
6318
|
-
const builtin =
|
|
6311
|
+
const builtin = action$1;
|
|
6319
6312
|
if (existingIndex >= 0) nextActions[existingIndex] = {
|
|
6320
6313
|
...nextActions[existingIndex],
|
|
6321
6314
|
...builtin
|
|
@@ -6326,7 +6319,7 @@ function resolveActions$1(targetId, zone, ownerActions) {
|
|
|
6326
6319
|
const items = group.sort((left, right) => left.seq - right.seq).flatMap((entry) => {
|
|
6327
6320
|
const { action: action$1 } = entry;
|
|
6328
6321
|
if (action$1.hidden || isReplacedCustom(entry)) return [];
|
|
6329
|
-
if (isCustomAction$1(action$1)) return [
|
|
6322
|
+
if (isCustomAction$1(action$1)) return [{ ...action$1 }];
|
|
6330
6323
|
const builtin = nextActions.find((item) => item.type === action$1.type);
|
|
6331
6324
|
return builtin ? [builtin] : [];
|
|
6332
6325
|
});
|
|
@@ -6345,13 +6338,9 @@ function resolveActions$1(targetId, zone, ownerActions) {
|
|
|
6345
6338
|
cursor += 1;
|
|
6346
6339
|
}
|
|
6347
6340
|
}
|
|
6348
|
-
} else
|
|
6341
|
+
} else extraActions.push(...items);
|
|
6349
6342
|
}
|
|
6350
|
-
return
|
|
6351
|
-
...startCustomActions,
|
|
6352
|
-
...nextActions,
|
|
6353
|
-
...endCustomActions
|
|
6354
|
-
];
|
|
6343
|
+
return require_position.positionActions(nextActions, extraActions).map(withoutRegistryMeta);
|
|
6355
6344
|
}
|
|
6356
6345
|
const crudActions = {
|
|
6357
6346
|
register(registration) {
|
|
@@ -6453,8 +6442,8 @@ function resolveOwnerActions(config, defaults) {
|
|
|
6453
6442
|
const items = resolved !== void 0 && resolved.length > 0 ? [...resolved] : [];
|
|
6454
6443
|
if (items.length === 0) return [...defaults];
|
|
6455
6444
|
if (items.some((item) => !isCustomAction(item))) return items;
|
|
6456
|
-
const startItems = items.filter((item) => isCustomAction(item) && item.position
|
|
6457
|
-
const endItems = items.filter((item) => isCustomAction(item) && item.position
|
|
6445
|
+
const startItems = items.filter((item) => isCustomAction(item) && require_position.matchesPosition(item.position, "start"));
|
|
6446
|
+
const endItems = items.filter((item) => isCustomAction(item) && !require_position.matchesPosition(item.position, "start"));
|
|
6458
6447
|
return [
|
|
6459
6448
|
...startItems,
|
|
6460
6449
|
...defaults,
|
|
@@ -9275,8 +9264,10 @@ Object.defineProperty(exports, 'Select', {
|
|
|
9275
9264
|
return __wordrhyme_shadcn_ui.Select;
|
|
9276
9265
|
}
|
|
9277
9266
|
});
|
|
9267
|
+
exports.actionPositionSchema = require_position.actionPositionSchema;
|
|
9278
9268
|
exports.cn = cn;
|
|
9279
9269
|
exports.coerceRowValues = coerceRowValues;
|
|
9270
|
+
exports.compareOrder = require_position.compareOrder;
|
|
9280
9271
|
exports.components = components;
|
|
9281
9272
|
exports.createActionsColumn = createActionsColumn;
|
|
9282
9273
|
exports.createEditFormSchema = createEditFormSchema;
|
|
@@ -9302,6 +9293,7 @@ exports.getUrlParams = getUrlParams;
|
|
|
9302
9293
|
exports.humanize = humanize;
|
|
9303
9294
|
exports.jaJP = jaJP;
|
|
9304
9295
|
exports.koKR = koKR;
|
|
9296
|
+
exports.matchesPosition = require_position.matchesPosition;
|
|
9305
9297
|
exports.noopToastAdapter = noopToastAdapter;
|
|
9306
9298
|
exports.normalizeDataSourceConfig = normalizeDataSourceConfig;
|
|
9307
9299
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -9313,6 +9305,7 @@ exports.parseCSV = parseCSV;
|
|
|
9313
9305
|
exports.parseImportFile = parseImportFile;
|
|
9314
9306
|
exports.parseJSON = parseJSON;
|
|
9315
9307
|
exports.parseZodField = parseZodField;
|
|
9308
|
+
exports.positionActions = require_position.positionActions;
|
|
9316
9309
|
exports.resolveLocale = resolveLocale;
|
|
9317
9310
|
exports.setDateFormatter = setDateFormatter;
|
|
9318
9311
|
exports.setSearchParams = setSearchParams;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { a as positionActions, i as matchesPosition, n as actionPositionSchema, r as compareOrder, t as ActionPosition } from "./position-DoBV7yB6.cjs";
|
|
1
2
|
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
2
3
|
import * as React$1 from "react";
|
|
3
4
|
import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
@@ -219,9 +220,9 @@ declare const filterItemSchema: z.ZodObject<{
|
|
|
219
220
|
variant: z.ZodEnum<{
|
|
220
221
|
number: "number";
|
|
221
222
|
boolean: "boolean";
|
|
223
|
+
date: "date";
|
|
222
224
|
text: "text";
|
|
223
225
|
range: "range";
|
|
224
|
-
date: "date";
|
|
225
226
|
dateRange: "dateRange";
|
|
226
227
|
select: "select";
|
|
227
228
|
multiSelect: "multiSelect";
|
|
@@ -691,8 +692,8 @@ type BatchCustomActionItem<TData> = BatchActionMeta & {
|
|
|
691
692
|
onClick?: (rows: TData[], context: BatchActionContext<TData>, event: React$1.MouseEvent<HTMLButtonElement>) => void;
|
|
692
693
|
/** 渲染自定义内容 */
|
|
693
694
|
component?: React$1.ReactNode | ((context: BatchActionContext<TData>) => React$1.ReactNode);
|
|
694
|
-
/**
|
|
695
|
-
position?:
|
|
695
|
+
/** start/end 仅在无内置项时生效(默认 end);也可指定锚点的 before/after。 */
|
|
696
|
+
position?: ActionPosition;
|
|
696
697
|
variant?: 'default' | 'destructive';
|
|
697
698
|
};
|
|
698
699
|
type BatchActionItem<TData> = BatchBuiltinActionItem<TData> | BatchCustomActionItem<TData>;
|
|
@@ -1270,7 +1271,7 @@ type RowCustomActionItem<T> = ActionMeta & {
|
|
|
1270
1271
|
label?: string;
|
|
1271
1272
|
onClick?: (row: T) => void;
|
|
1272
1273
|
component?: ActionComponent<AutoCrudRowActionContext<T>>;
|
|
1273
|
-
position?:
|
|
1274
|
+
position?: ActionPosition;
|
|
1274
1275
|
separator?: boolean;
|
|
1275
1276
|
variant?: 'default' | 'destructive';
|
|
1276
1277
|
};
|
|
@@ -1312,8 +1313,8 @@ type ToolbarCustomActionItem = ActionMeta & {
|
|
|
1312
1313
|
type: 'custom';
|
|
1313
1314
|
/** 渲染自定义内容 */
|
|
1314
1315
|
component: ActionComponent<AutoCrudToolbarContext>;
|
|
1315
|
-
/**
|
|
1316
|
-
position?:
|
|
1316
|
+
/** start/end 仅在无内置项时生效(默认 end);也可指定锚点的 before/after。 */
|
|
1317
|
+
position?: ActionPosition;
|
|
1317
1318
|
};
|
|
1318
1319
|
type ToolbarActionItem = ToolbarBuiltinActionItem | ToolbarCustomActionItem;
|
|
1319
1320
|
type ToolbarActionConfig = ToolbarActionItem[] | ((defaults: ToolbarBuiltinActionItem[]) => ToolbarActionItem[]);
|
|
@@ -1720,7 +1721,7 @@ type CrudActionBase = {
|
|
|
1720
1721
|
id?: string;
|
|
1721
1722
|
order?: number;
|
|
1722
1723
|
hidden?: boolean;
|
|
1723
|
-
position?:
|
|
1724
|
+
position?: ActionPosition;
|
|
1724
1725
|
};
|
|
1725
1726
|
type CrudActionEntry<TAction extends CrudActionBase = CrudActionBase> = {
|
|
1726
1727
|
targetId: string;
|
|
@@ -2103,4 +2104,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
2103
2104
|
*/
|
|
2104
2105
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
2105
2106
|
//#endregion
|
|
2106
|
-
export { type ActionConfig, type ActionItem, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, type AutoCrudRowOpenOptions, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableClassNames, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatPreset, type DateFormatter, type DateLocaleOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldTableDisplay, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionDialogProps, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type TablePaginationOptions, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, cn, coerceRowValues, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
|
2107
|
+
export { type ActionConfig, type ActionItem, type ActionPosition, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, type AutoCrudRowOpenOptions, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableClassNames, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatPreset, type DateFormatter, type DateLocaleOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldTableDisplay, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionDialogProps, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type TablePaginationOptions, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, actionPositionSchema, cn, coerceRowValues, compareOrder, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, matchesPosition, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, positionActions, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { a as positionActions, i as matchesPosition, n as actionPositionSchema, r as compareOrder, t as ActionPosition } from "./position-mYekVBBH.js";
|
|
1
2
|
import * as React$1 from "react";
|
|
2
3
|
import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
3
4
|
import { Column, ColumnDef, ColumnMeta, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
|
|
@@ -219,9 +220,9 @@ declare const filterItemSchema: z.ZodObject<{
|
|
|
219
220
|
variant: z.ZodEnum<{
|
|
220
221
|
number: "number";
|
|
221
222
|
boolean: "boolean";
|
|
223
|
+
date: "date";
|
|
222
224
|
text: "text";
|
|
223
225
|
range: "range";
|
|
224
|
-
date: "date";
|
|
225
226
|
dateRange: "dateRange";
|
|
226
227
|
select: "select";
|
|
227
228
|
multiSelect: "multiSelect";
|
|
@@ -691,8 +692,8 @@ type BatchCustomActionItem<TData> = BatchActionMeta & {
|
|
|
691
692
|
onClick?: (rows: TData[], context: BatchActionContext<TData>, event: React$1.MouseEvent<HTMLButtonElement>) => void;
|
|
692
693
|
/** 渲染自定义内容 */
|
|
693
694
|
component?: React$1.ReactNode | ((context: BatchActionContext<TData>) => React$1.ReactNode);
|
|
694
|
-
/**
|
|
695
|
-
position?:
|
|
695
|
+
/** start/end 仅在无内置项时生效(默认 end);也可指定锚点的 before/after。 */
|
|
696
|
+
position?: ActionPosition;
|
|
696
697
|
variant?: 'default' | 'destructive';
|
|
697
698
|
};
|
|
698
699
|
type BatchActionItem<TData> = BatchBuiltinActionItem<TData> | BatchCustomActionItem<TData>;
|
|
@@ -1270,7 +1271,7 @@ type RowCustomActionItem<T> = ActionMeta & {
|
|
|
1270
1271
|
label?: string;
|
|
1271
1272
|
onClick?: (row: T) => void;
|
|
1272
1273
|
component?: ActionComponent<AutoCrudRowActionContext<T>>;
|
|
1273
|
-
position?:
|
|
1274
|
+
position?: ActionPosition;
|
|
1274
1275
|
separator?: boolean;
|
|
1275
1276
|
variant?: 'default' | 'destructive';
|
|
1276
1277
|
};
|
|
@@ -1312,8 +1313,8 @@ type ToolbarCustomActionItem = ActionMeta & {
|
|
|
1312
1313
|
type: 'custom';
|
|
1313
1314
|
/** 渲染自定义内容 */
|
|
1314
1315
|
component: ActionComponent<AutoCrudToolbarContext>;
|
|
1315
|
-
/**
|
|
1316
|
-
position?:
|
|
1316
|
+
/** start/end 仅在无内置项时生效(默认 end);也可指定锚点的 before/after。 */
|
|
1317
|
+
position?: ActionPosition;
|
|
1317
1318
|
};
|
|
1318
1319
|
type ToolbarActionItem = ToolbarBuiltinActionItem | ToolbarCustomActionItem;
|
|
1319
1320
|
type ToolbarActionConfig = ToolbarActionItem[] | ((defaults: ToolbarBuiltinActionItem[]) => ToolbarActionItem[]);
|
|
@@ -1720,7 +1721,7 @@ type CrudActionBase = {
|
|
|
1720
1721
|
id?: string;
|
|
1721
1722
|
order?: number;
|
|
1722
1723
|
hidden?: boolean;
|
|
1723
|
-
position?:
|
|
1724
|
+
position?: ActionPosition;
|
|
1724
1725
|
};
|
|
1725
1726
|
type CrudActionEntry<TAction extends CrudActionBase = CrudActionBase> = {
|
|
1726
1727
|
targetId: string;
|
|
@@ -2103,4 +2104,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
2103
2104
|
*/
|
|
2104
2105
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
2105
2106
|
//#endregion
|
|
2106
|
-
export { type ActionConfig, type ActionItem, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, type AutoCrudRowOpenOptions, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableClassNames, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatPreset, type DateFormatter, type DateLocaleOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldTableDisplay, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionDialogProps, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type TablePaginationOptions, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, cn, coerceRowValues, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
|
2107
|
+
export { type ActionConfig, type ActionItem, type ActionPosition, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, type AutoCrudRowOpenOptions, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableClassNames, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatPreset, type DateFormatter, type DateLocaleOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldTableDisplay, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionDialogProps, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type TablePaginationOptions, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, actionPositionSchema, cn, coerceRowValues, compareOrder, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, matchesPosition, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, positionActions, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i as positionActions, n as compareOrder, r as matchesPosition, t as actionPositionSchema } from "./position--p6kJnYA.js";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
3
4
|
import { ArrowDownUp, BadgeCheck, CalendarIcon, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, CommandIcon, Download, Ellipsis, EyeOff, FileDown, FileSpreadsheetIcon, GripVertical, ListFilter, ListFilterIcon, Loader2, PlusCircle, RefreshCw, Settings2, Text, Trash2, Upload, X, XCircle } from "lucide-react";
|
|
@@ -4074,7 +4075,7 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
|
|
|
4074
4075
|
{ type: "export" },
|
|
4075
4076
|
{ type: "delete" }
|
|
4076
4077
|
]) : actions;
|
|
4077
|
-
|
|
4078
|
+
let resolvedActions = configuredActions?.filter((action$1) => !action$1.hidden);
|
|
4078
4079
|
if (configuredActions === void 0) return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4079
4080
|
renderBuiltinAction({ type: "batchUpdate" }),
|
|
4080
4081
|
extraActions,
|
|
@@ -4082,7 +4083,20 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
|
|
|
4082
4083
|
renderBuiltinAction({ type: "delete" })
|
|
4083
4084
|
] });
|
|
4084
4085
|
if (!resolvedActions || resolvedActions.length === 0) return null;
|
|
4085
|
-
|
|
4086
|
+
let hasBuiltin = resolvedActions.some((action$1) => action$1.type !== "custom");
|
|
4087
|
+
if (resolvedActions.some((action$1) => "position" in action$1 && typeof action$1.position === "object")) if (!hasBuiltin) {
|
|
4088
|
+
resolvedActions = positionActions([
|
|
4089
|
+
{ type: "batchUpdate" },
|
|
4090
|
+
...extraActions ? [{
|
|
4091
|
+
type: "custom",
|
|
4092
|
+
component: extraActions
|
|
4093
|
+
}] : [],
|
|
4094
|
+
...showDefaultExport ? [{ type: "export" }] : [],
|
|
4095
|
+
{ type: "delete" }
|
|
4096
|
+
], resolvedActions);
|
|
4097
|
+
hasBuiltin = true;
|
|
4098
|
+
} else resolvedActions = positionActions(resolvedActions);
|
|
4099
|
+
if (!hasBuiltin) {
|
|
4086
4100
|
const startNodes = resolvedActions.filter(isBatchCustomAction).filter((action$1) => action$1.position === "start").map((action$1, index$1) => renderCustomAction(action$1, index$1));
|
|
4087
4101
|
const endNodes = resolvedActions.filter(isBatchCustomAction).filter((action$1) => action$1.position !== "start").map((action$1, index$1) => renderCustomAction(action$1, index$1));
|
|
4088
4102
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -6235,15 +6249,18 @@ function unregisterOwnerActions(ownerId, options = {}, shouldNotify = true) {
|
|
|
6235
6249
|
if (changed && shouldNotify) notify();
|
|
6236
6250
|
}
|
|
6237
6251
|
function sortEntries(left, right) {
|
|
6238
|
-
const orderDiff = left
|
|
6252
|
+
const orderDiff = compareOrder(left, right);
|
|
6239
6253
|
if (orderDiff !== 0) return orderDiff;
|
|
6240
6254
|
const ownerDiff = left.ownerId.localeCompare(right.ownerId);
|
|
6241
6255
|
if (ownerDiff !== 0) return ownerDiff;
|
|
6242
6256
|
return left.seq - right.seq;
|
|
6243
6257
|
}
|
|
6244
6258
|
function withoutRegistryMeta(action$1) {
|
|
6245
|
-
const { id, order,...rest } = action$1;
|
|
6246
|
-
return
|
|
6259
|
+
const { id, order, position,...rest } = action$1;
|
|
6260
|
+
return {
|
|
6261
|
+
...rest,
|
|
6262
|
+
...typeof position === "string" ? { position } : {}
|
|
6263
|
+
};
|
|
6247
6264
|
}
|
|
6248
6265
|
function isCustomAction$1(action$1) {
|
|
6249
6266
|
return action$1.type === "custom";
|
|
@@ -6258,12 +6275,11 @@ function resolveActions$1(targetId, zone, ownerActions) {
|
|
|
6258
6275
|
if (isCustomAction$1(action$1) && action$1.id && !isMaskedCustom(action$1)) customOverrides.set(action$1.id, entry);
|
|
6259
6276
|
}
|
|
6260
6277
|
const ownerCustomIds = new Set(ownerActions.flatMap((action$1) => isCustomAction$1(action$1) && action$1.id ? [action$1.id] : []));
|
|
6261
|
-
const baseActions = ownerActions.filter((action$1) => !action$1.hidden && !isMaskedCustom(action$1)).map((action$1) =>
|
|
6278
|
+
const baseActions = ownerActions.filter((action$1) => !action$1.hidden && !isMaskedCustom(action$1)).map((action$1) => ({ ...isCustomAction$1(action$1) && action$1.id ? customOverrides.get(action$1.id)?.action ?? action$1 : action$1 }));
|
|
6262
6279
|
const isReplacedCustom = ({ action: action$1, seq: seq$1 }) => isCustomAction$1(action$1) && Boolean(action$1.id && (ownerCustomIds.has(action$1.id) || customOverrides.get(action$1.id)?.seq !== seq$1));
|
|
6263
|
-
if (registered.length === 0) return baseActions;
|
|
6280
|
+
if (registered.length === 0) return positionActions(baseActions).map(withoutRegistryMeta);
|
|
6264
6281
|
const nextActions = [...baseActions];
|
|
6265
|
-
const
|
|
6266
|
-
const endCustomActions = [];
|
|
6282
|
+
const extraActions = [];
|
|
6267
6283
|
const groups = /* @__PURE__ */ new Map();
|
|
6268
6284
|
for (const entry of registered) {
|
|
6269
6285
|
if (isMaskedCustom(entry.action)) continue;
|
|
@@ -6277,7 +6293,7 @@ function resolveActions$1(targetId, zone, ownerActions) {
|
|
|
6277
6293
|
if (existingIndex >= 0) nextActions.splice(existingIndex, 1);
|
|
6278
6294
|
continue;
|
|
6279
6295
|
}
|
|
6280
|
-
const builtin =
|
|
6296
|
+
const builtin = action$1;
|
|
6281
6297
|
if (existingIndex >= 0) nextActions[existingIndex] = {
|
|
6282
6298
|
...nextActions[existingIndex],
|
|
6283
6299
|
...builtin
|
|
@@ -6288,7 +6304,7 @@ function resolveActions$1(targetId, zone, ownerActions) {
|
|
|
6288
6304
|
const items = group.sort((left, right) => left.seq - right.seq).flatMap((entry) => {
|
|
6289
6305
|
const { action: action$1 } = entry;
|
|
6290
6306
|
if (action$1.hidden || isReplacedCustom(entry)) return [];
|
|
6291
|
-
if (isCustomAction$1(action$1)) return [
|
|
6307
|
+
if (isCustomAction$1(action$1)) return [{ ...action$1 }];
|
|
6292
6308
|
const builtin = nextActions.find((item) => item.type === action$1.type);
|
|
6293
6309
|
return builtin ? [builtin] : [];
|
|
6294
6310
|
});
|
|
@@ -6307,13 +6323,9 @@ function resolveActions$1(targetId, zone, ownerActions) {
|
|
|
6307
6323
|
cursor += 1;
|
|
6308
6324
|
}
|
|
6309
6325
|
}
|
|
6310
|
-
} else
|
|
6326
|
+
} else extraActions.push(...items);
|
|
6311
6327
|
}
|
|
6312
|
-
return
|
|
6313
|
-
...startCustomActions,
|
|
6314
|
-
...nextActions,
|
|
6315
|
-
...endCustomActions
|
|
6316
|
-
];
|
|
6328
|
+
return positionActions(nextActions, extraActions).map(withoutRegistryMeta);
|
|
6317
6329
|
}
|
|
6318
6330
|
const crudActions = {
|
|
6319
6331
|
register(registration) {
|
|
@@ -6415,8 +6427,8 @@ function resolveOwnerActions(config, defaults) {
|
|
|
6415
6427
|
const items = resolved !== void 0 && resolved.length > 0 ? [...resolved] : [];
|
|
6416
6428
|
if (items.length === 0) return [...defaults];
|
|
6417
6429
|
if (items.some((item) => !isCustomAction(item))) return items;
|
|
6418
|
-
const startItems = items.filter((item) => isCustomAction(item) && item.position
|
|
6419
|
-
const endItems = items.filter((item) => isCustomAction(item) && item.position
|
|
6430
|
+
const startItems = items.filter((item) => isCustomAction(item) && matchesPosition(item.position, "start"));
|
|
6431
|
+
const endItems = items.filter((item) => isCustomAction(item) && !matchesPosition(item.position, "start"));
|
|
6420
6432
|
return [
|
|
6421
6433
|
...startItems,
|
|
6422
6434
|
...defaults,
|
|
@@ -9209,4 +9221,4 @@ function createMemoryDataSource(initialData = []) {
|
|
|
9209
9221
|
}
|
|
9210
9222
|
|
|
9211
9223
|
//#endregion
|
|
9212
|
-
export { AutoCrudTable, AutoForm, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, CrudFormModal, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableToolbar, DataTableViewOptions, ExportDialog, ImportDialog, MultiCombobox, SchemaAdapter, Select, cn, coerceRowValues, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
|
9224
|
+
export { AutoCrudTable, AutoForm, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, CrudFormModal, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableToolbar, DataTableViewOptions, ExportDialog, ImportDialog, MultiCombobox, SchemaAdapter, Select, actionPositionSchema, cn, coerceRowValues, compareOrder, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, matchesPosition, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, positionActions, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/position.ts
|
|
4
|
+
const actionPositionSchema = z.union([z.enum(["start", "end"]), z.object({
|
|
5
|
+
anchor: z.string().min(1),
|
|
6
|
+
side: z.enum(["before", "after"])
|
|
7
|
+
})]);
|
|
8
|
+
function matchesPosition(position, point) {
|
|
9
|
+
if (typeof position !== "object" || typeof point !== "object") return position === point;
|
|
10
|
+
return position.anchor === point.anchor && position.side === point.side;
|
|
11
|
+
}
|
|
12
|
+
function compareOrder(left, right) {
|
|
13
|
+
return (left.order ?? 100) - (right.order ?? 100);
|
|
14
|
+
}
|
|
15
|
+
/** Resolve relative positions after owner ordering and overrides, before removing IDs. */
|
|
16
|
+
function positionActions(items, fills = []) {
|
|
17
|
+
const anchored = /* @__PURE__ */ new Map();
|
|
18
|
+
const base = [];
|
|
19
|
+
for (const item of [
|
|
20
|
+
...fills.filter((fill) => matchesPosition(fill.position, "start")),
|
|
21
|
+
...items,
|
|
22
|
+
...fills.filter((fill) => !matchesPosition(fill.position, "start"))
|
|
23
|
+
]) {
|
|
24
|
+
if (item.position !== void 0) actionPositionSchema.parse(item.position);
|
|
25
|
+
if (typeof item.position !== "object") {
|
|
26
|
+
base.push(item);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const group = anchored.get(item.position.anchor) ?? [];
|
|
30
|
+
group.push(item);
|
|
31
|
+
anchored.set(item.position.anchor, group);
|
|
32
|
+
}
|
|
33
|
+
const result = base.flatMap((item) => {
|
|
34
|
+
const anchor = item.id ?? (item.type === "custom" ? void 0 : item.type);
|
|
35
|
+
if (!anchor) return [item];
|
|
36
|
+
const group = anchored.get(anchor) ?? [];
|
|
37
|
+
anchored.delete(anchor);
|
|
38
|
+
group.sort(compareOrder);
|
|
39
|
+
return [
|
|
40
|
+
...group.filter((action) => matchesPosition(action.position, {
|
|
41
|
+
anchor,
|
|
42
|
+
side: "before"
|
|
43
|
+
})),
|
|
44
|
+
item,
|
|
45
|
+
...group.filter((action) => matchesPosition(action.position, {
|
|
46
|
+
anchor,
|
|
47
|
+
side: "after"
|
|
48
|
+
}))
|
|
49
|
+
];
|
|
50
|
+
});
|
|
51
|
+
for (const anchor of anchored.keys()) console.warn(`[Actions] Unavailable anchor "${anchor}"`);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { positionActions as i, compareOrder as n, matchesPosition as r, actionPositionSchema as t };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let zod = require("zod");
|
|
25
|
+
zod = __toESM(zod);
|
|
26
|
+
|
|
27
|
+
//#region src/position.ts
|
|
28
|
+
const actionPositionSchema = zod.z.union([zod.z.enum(["start", "end"]), zod.z.object({
|
|
29
|
+
anchor: zod.z.string().min(1),
|
|
30
|
+
side: zod.z.enum(["before", "after"])
|
|
31
|
+
})]);
|
|
32
|
+
function matchesPosition(position, point) {
|
|
33
|
+
if (typeof position !== "object" || typeof point !== "object") return position === point;
|
|
34
|
+
return position.anchor === point.anchor && position.side === point.side;
|
|
35
|
+
}
|
|
36
|
+
function compareOrder(left, right) {
|
|
37
|
+
return (left.order ?? 100) - (right.order ?? 100);
|
|
38
|
+
}
|
|
39
|
+
/** Resolve relative positions after owner ordering and overrides, before removing IDs. */
|
|
40
|
+
function positionActions(items, fills = []) {
|
|
41
|
+
const anchored = /* @__PURE__ */ new Map();
|
|
42
|
+
const base = [];
|
|
43
|
+
for (const item of [
|
|
44
|
+
...fills.filter((fill) => matchesPosition(fill.position, "start")),
|
|
45
|
+
...items,
|
|
46
|
+
...fills.filter((fill) => !matchesPosition(fill.position, "start"))
|
|
47
|
+
]) {
|
|
48
|
+
if (item.position !== void 0) actionPositionSchema.parse(item.position);
|
|
49
|
+
if (typeof item.position !== "object") {
|
|
50
|
+
base.push(item);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const group = anchored.get(item.position.anchor) ?? [];
|
|
54
|
+
group.push(item);
|
|
55
|
+
anchored.set(item.position.anchor, group);
|
|
56
|
+
}
|
|
57
|
+
const result = base.flatMap((item) => {
|
|
58
|
+
const anchor = item.id ?? (item.type === "custom" ? void 0 : item.type);
|
|
59
|
+
if (!anchor) return [item];
|
|
60
|
+
const group = anchored.get(anchor) ?? [];
|
|
61
|
+
anchored.delete(anchor);
|
|
62
|
+
group.sort(compareOrder);
|
|
63
|
+
return [
|
|
64
|
+
...group.filter((action) => matchesPosition(action.position, {
|
|
65
|
+
anchor,
|
|
66
|
+
side: "before"
|
|
67
|
+
})),
|
|
68
|
+
item,
|
|
69
|
+
...group.filter((action) => matchesPosition(action.position, {
|
|
70
|
+
anchor,
|
|
71
|
+
side: "after"
|
|
72
|
+
}))
|
|
73
|
+
];
|
|
74
|
+
});
|
|
75
|
+
for (const anchor of anchored.keys()) console.warn(`[Actions] Unavailable anchor "${anchor}"`);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
Object.defineProperty(exports, '__toESM', {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () {
|
|
83
|
+
return __toESM;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(exports, 'actionPositionSchema', {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () {
|
|
89
|
+
return actionPositionSchema;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(exports, 'compareOrder', {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function () {
|
|
95
|
+
return compareOrder;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(exports, 'matchesPosition', {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return matchesPosition;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, 'positionActions', {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () {
|
|
107
|
+
return positionActions;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/position.d.ts
|
|
4
|
+
declare const actionPositionSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
5
|
+
start: "start";
|
|
6
|
+
end: "end";
|
|
7
|
+
}>, z.ZodObject<{
|
|
8
|
+
anchor: z.ZodString;
|
|
9
|
+
side: z.ZodEnum<{
|
|
10
|
+
before: "before";
|
|
11
|
+
after: "after";
|
|
12
|
+
}>;
|
|
13
|
+
}, z.core.$strip>]>;
|
|
14
|
+
type ActionPosition = z.infer<typeof actionPositionSchema>;
|
|
15
|
+
declare function matchesPosition(position?: ActionPosition, point?: ActionPosition): boolean;
|
|
16
|
+
declare function compareOrder(left: {
|
|
17
|
+
order?: number;
|
|
18
|
+
}, right: {
|
|
19
|
+
order?: number;
|
|
20
|
+
}): number;
|
|
21
|
+
/** Resolve relative positions after owner ordering and overrides, before removing IDs. */
|
|
22
|
+
declare function positionActions<T extends {
|
|
23
|
+
id?: string;
|
|
24
|
+
type: string;
|
|
25
|
+
order?: number;
|
|
26
|
+
position?: ActionPosition;
|
|
27
|
+
}>(items: readonly T[], fills?: readonly T[]): T[];
|
|
28
|
+
//#endregion
|
|
29
|
+
export { positionActions as a, matchesPosition as i, actionPositionSchema as n, compareOrder as r, ActionPosition as t };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/position.d.ts
|
|
4
|
+
declare const actionPositionSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
5
|
+
start: "start";
|
|
6
|
+
end: "end";
|
|
7
|
+
}>, z.ZodObject<{
|
|
8
|
+
anchor: z.ZodString;
|
|
9
|
+
side: z.ZodEnum<{
|
|
10
|
+
before: "before";
|
|
11
|
+
after: "after";
|
|
12
|
+
}>;
|
|
13
|
+
}, z.core.$strip>]>;
|
|
14
|
+
type ActionPosition = z.infer<typeof actionPositionSchema>;
|
|
15
|
+
declare function matchesPosition(position?: ActionPosition, point?: ActionPosition): boolean;
|
|
16
|
+
declare function compareOrder(left: {
|
|
17
|
+
order?: number;
|
|
18
|
+
}, right: {
|
|
19
|
+
order?: number;
|
|
20
|
+
}): number;
|
|
21
|
+
/** Resolve relative positions after owner ordering and overrides, before removing IDs. */
|
|
22
|
+
declare function positionActions<T extends {
|
|
23
|
+
id?: string;
|
|
24
|
+
type: string;
|
|
25
|
+
order?: number;
|
|
26
|
+
position?: ActionPosition;
|
|
27
|
+
}>(items: readonly T[], fills?: readonly T[]): T[];
|
|
28
|
+
//#endregion
|
|
29
|
+
export { positionActions as a, matchesPosition as i, actionPositionSchema as n, compareOrder as r, ActionPosition as t };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const require_position = require('./position-BlO0bPw6.cjs');
|
|
2
|
+
|
|
3
|
+
exports.actionPositionSchema = require_position.actionPositionSchema;
|
|
4
|
+
exports.compareOrder = require_position.compareOrder;
|
|
5
|
+
exports.matchesPosition = require_position.matchesPosition;
|
|
6
|
+
exports.positionActions = require_position.positionActions;
|
package/dist/position.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.2",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -20,7 +20,12 @@
|
|
|
20
20
|
"import": "./dist/index.js",
|
|
21
21
|
"require": "./dist/index.cjs"
|
|
22
22
|
},
|
|
23
|
-
"./styles.css": "./dist/styles.css"
|
|
23
|
+
"./styles.css": "./dist/styles.css",
|
|
24
|
+
"./position": {
|
|
25
|
+
"types": "./dist/position.d.ts",
|
|
26
|
+
"import": "./dist/position.js",
|
|
27
|
+
"require": "./dist/position.cjs"
|
|
28
|
+
}
|
|
24
29
|
},
|
|
25
30
|
"files": [
|
|
26
31
|
"dist"
|
|
@@ -65,8 +70,8 @@
|
|
|
65
70
|
"nanoid": "^5.1.6",
|
|
66
71
|
"tailwind-merge": "^3.5.0",
|
|
67
72
|
"vaul": "^1.1.2",
|
|
68
|
-
"@wordrhyme/formily-shadcn": "2.1.1",
|
|
69
73
|
"@wordrhyme/shadcn": "2.0.1",
|
|
74
|
+
"@wordrhyme/formily-shadcn": "2.1.1",
|
|
70
75
|
"@wordrhyme/shadcn-ui": "2.1.1"
|
|
71
76
|
},
|
|
72
77
|
"devDependencies": {
|
|
@@ -88,9 +93,9 @@
|
|
|
88
93
|
"tsdown": "^0.15.12",
|
|
89
94
|
"typescript": "^5.9.3",
|
|
90
95
|
"vitest": "^3.2.4",
|
|
91
|
-
"@internal/eslint-config": "0.3.0",
|
|
92
|
-
"@internal/prettier-config": "0.0.1",
|
|
93
96
|
"@internal/tsconfig": "0.1.0",
|
|
97
|
+
"@internal/prettier-config": "0.0.1",
|
|
98
|
+
"@internal/eslint-config": "0.3.0",
|
|
94
99
|
"@internal/tsdown-config": "0.1.0",
|
|
95
100
|
"@internal/vitest-config": "0.1.0"
|
|
96
101
|
},
|